Welcome, Guest Login

Support Center

Push Notification and Third Party Apps

Last Updated: Jun 25, 2014 10:45AM EDT

Third-Party Apps

If your app is built using Objective C, you make the following changes to be ready to handle push notification messages under iOS.

Register for notifications when the app starts up.

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Check whether the launch was triggered by a notification.
    id userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if ([userInfo isKindOfClass:[NSDictionary class]]) {
       // Yes, save the notification for after the launch event.
       self.pushNotificationUserInfo = userInfo;
    }

    // Initiate registration for the types of notifications you want to receive for your app.
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound)];

    // Process the notification (if there was one on launch) in the runloop.
    // Do at the end to be sure your environment is set up to handle it appropriately.
    if (self.pushNotificationUserInfo)
       [self performSelector:@selector(application:didReceiveRemoteNotification:) withObject:self.userInfo afterDelay:0];
  }

Set up App Delegate to handle registration and events. It is essential the app registers with the EachScape service provider, supplying the unique Device ID

  - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
    // Save the token (optional).
    
    // Construct the callback URL with the appropriate information (See notes below).
    
    // Create HTTP request and start it.
    
  }

  - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    // Here we set up a timer to retry if the registration failed
    self.pushRegistrationTimer = [NSTimer scheduledTimerWithTimeInterval:PushRegistrationTimerInterval
                                                                  target:self
                                                                selector:@selector(pushRegistrationTimerFired:)
                                                                userInfo:nil
                                                                 repeats:NO];
  }

  - (void)pushRegistrationTimerFired:(NSTimer *)timer {
    // Retry the registration
    self.pushRegistrationTimer = nil;
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound)];
    }
  }

  - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    // Handle the notification here.  Check the documentation for the dictionary values that will be provided with each type of notification.
  }

The referenced URL must be accessed every time the app launches. The reference URL should be requested via a GET. The endpoint is push.eachscape.com/subscription/add and the following query parameters must all be present:

Query Parameter Value
aid An application ID string provided by EachScape
bid The bundle identifier used when the provisioning profile was created. For example “com.example.myapp”
dt The deviceToken from the call to didRegisterForRemoteNotificationsWithDeviceToken
os The string “ios” should be supplied.

To unsubscribe a device from push notifications, you may send an HTTP GET request to push.eachscape.com/subscription/remove with the following parameters:

Query Parameter Value
bid The bundle identifier used when the provisioning profile was created. For example “com.example.myapp”
dt The deviceToken from the call to didRegisterForRemoteNotificationsWithDeviceToken
os The string “ios” should be supplied.

Help us improve! Rate this article:

Yes I found this article helpful

Ask a Question   

support@eachscape.com
http://assets2.desk.com/
false
eachscape
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete