Client Libraries

Code iOS/Objective C

We recommend using Cocoapods to integrate with ZeroPush on the client side.

Inbox Installation

To install the ZeroPush Pod, add the following to your Podfile

pod 'ZeroPush', '~> 2.0'

and install the Pods

$> pod install

This will add the ZeroPush source to your Pods project in the xcworkspace.

Alternatively, if your project does not use Cocoapods, you can add ZeroPush from source. It can downloaded from our GitHub page:

Settings 3 Configuration

After the client library has been installed, add the following to your AppDelegate.

//In AppDelegate.h - Add the ZeroPushDelegate

#import "ZeroPush.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate, ZeroPushDelegate>

// In AppDelegate.m
- (void)applicationDidBecomeActive:(UIApplication *)application
    [ZeroPush engageWithAPIKey:@"your-zeropush-app-token" delegate:self];

    //now ask the user if they want to receive push notifications. You can place this in another part of your app.
    [[ZeroPush shared] registerForRemoteNotifications];

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)tokenData
    // Call the convenience method registerDeviceToken, this helps us track device tokens for you
    [[ZeroPush shared] registerDeviceToken:tokenData];

    // This would be a good time to save the token and associate it with a user that you want to notify later.
    NSString *tokenString = [ZeroPush deviceTokenFromData:tokenData];
    NSLog(@"%@", tokenString);

    // For instance you can associate it with a user's email address
    // [[ZeroPush shared] subscribeToChannel:@""];
    // You can then use the /broadcast endpoint to notify all devices subscribed to that email address. No need to save tokens!
    // Don't forget to unsubscribe from the channel when the user logs out of your app!

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    NSLog(@"%@", [error description]);
    //Common reason for errors:
    //  1.) Simulator does not support receiving push notifications
    //  2.) User rejected push alert
    //  3.) "no valid 'aps-environment' entitlement string found for application"
    //      This means your provisioning profile does not have Push Notifications configured.
updated on Sun Feb 7 18:41:03 2016