Skip to content

Enabling Apple Push Notifications (APNS)

(Optional) Enable Apple Push Notifications (APNS) for an iOS application.

Procedure

  1. Enable the certificate for push. Use the Apple Push Notification service to propagate information from the backend to the device. Use the native iOS push services to enable APNS for iOS applications. For information on enabling certificates for APNS, see the Apple Web site at: http://developer.apple.com/xcode/

  2. Configure APNS Push using the cockpit on the server-side to receive APNS.

  3. Add these two methods into the AppDelegate class to fetch the device token at the client side:

    objc-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{NSString *devToken=[[[NSString alloc]initWithData:deviceToken encoding:NSUTF8StringEncoding]autorelease];NSLog(@"Device Token: %@",devToken);}-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{NSLog(@"Error Occurred: %@",[error description]);}

  4. After successful registration, use the class SMPAppSettings to set the device token received in didRegisterForRemoteNotificationsWithDeviceToken. The following code illustrates this method:

    objcNSError* error = nil;NSDictionary *props = [NSMutableDictionary dictionary];[props setValue:deviceToken forKey:@"d:ApnsDeviceToken"];[appSettings setConfigProperty:props error:&error];if (error) {NSLog(@"ERROR: %@",error);}