Preparing an Application for Apple Push Notification Service

There are several development steps to perform before the administrator can configure the Apple Push Notification Service (APNS).

Note: Review complete details in the iPhone OS Enterprise Deployment Guide at http://manuals.info.apple.com/en_US/Enterprise_Deployment_Guide.pdf.
  1. Sign up for the iPhone Developer Program, which gives you access to the Developer Connection portal. Registering as an enterprise developer gets you the certificate you need to sign applications.
  2. Configure your application to use make use of Keychain as persistent storage for the database encryption key.
  3. Create an App ID and ensure that it is configured to use Apple Push Notification Service (APNS).

    Do not use wildcard characters in App IDs for iPhone applications that use APNS.

    Verify that your info.plist file has the correct App ID and application name. Also, in Xcode, right-click Targets < <your_app_target> and select Get Info to verify the App ID and App name.

  4. Create and download an enterprise APNS certificate that uses Keychain Access in the Mac OS. The information in the certificate request must use a different common name than the development certificate that may already exist. The reason for this naming requirement is that the enterprise certificate creates a private key, which must be distinct from the development key. Import the certificate as a login Keychain, not as a system Keychain. Validate that the certificate is associated with the key in the Keychain Access application. Get a copy of this certificate.
  5. Create an enterprise provisioning profile and include the required device IDs with the enterprise certificate. The provisioning profile authorizes devices to use applications you have signed.
  6. Create the Xcode project, ensuring the bundle identifier corresponds to the bundle identifier in the specified App ID.
  7. To enable the APNS protocol, you must implement several methods in the application by adding the code below:
    Note: The location of these methods in the code depends on the application; see the APNS documentation for the correct location.
    //Enable APNS
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
        (UIRemoteNotificationTypeBadge | 
         UIRemoteNotificationTypeSound | 
         UIRemoteNotificationTypeAlert)];
    
    * 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 didRegisterForRemoteNotificationsWithDeviceToken:
      (NSData *)devToken 
    {
    	MBOLogInfo(@"In did register for Remote Notifications", devToken);
        [SUPPushNotification setupForPush:app];
    	[SUPPushNotification deviceTokenForPush:app deviceToken:devToken];
    }
    
    * Callback by the system if registering for remote notification failed. 
    
    - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:
          (NSError *)err {
            MBOLogError(@"Error in registration. Error: %@", err);
           }
    
    // You can alternately implement the pushRegistrationFailed API:
    
    // +(void)pushRegistrationFailed:(UIApplication*)application errorInfo: (NSError *)err
    
    
    * Callback when notification is sent. 
    
    
    - (void)application:(UIApplication *)app didReceiveRemoteNotification:(NSDictionary *)
       userInfo 
    {
    	MBOLogInfo(@"In did receive  Remote Notifications", userInfo);
    }
    
    You can alternately implement the pushNotification API
    +(void)pushNotification:(UIApplication*)application
    notifyData:(NSDictionary *)userInfo