Sample Code to Enable APNS

Provides a code snippet on how to enable Apple Push Notification Services on your device.

Examples

  • Enable APNS
    //Enable APNS
    To enable APNS, you need to implement the following in the application delegate of the application that has to receive notifications.
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOp-tions:(NSDictionary *)launchOptions {    
    	[LiteSUPMessagingClient setupForPush:application];
    }
    * Callback by the system where the token is provided to the client application so that this
     can be passed on to the provider. In this case, “deviceTokenForPush” and “setupForPush” 
    are APIs provided by SUP to enable APNS and pass the token to SUP Server
    
    - (void)application:(UIApplication *)app didRegisterForRemoteNotifications-WithDe-viceToken:(NSData *)deviceToken { 
    	[LiteSUPMessagingClient deviceTokenForPush:app deviceToken:deviceToken];
    }
    * Callback by the system if registering for remote notification failed. 
    - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotifica-tionsWi-thError:(NSError *)err {
    	[LiteSUPMessagingClient pushRegistrationFailed:app errorInfo:err];
           }
    // You can alternately implement the pushRegistrationFailed API:
    // +(void)pushRegistrationFailed:(UIApplication*)application errorInfo: (NSError *)err
    * Callback when notification is sent. 
    - (void)application:(UIApplication *)application didReceiveRemoteNotifica-tion:(NSDictionary *)userInfo {
    	[LiteSUPMessagingClient pushNotification:application notifyDa-ta:userInfo];
    }