Skip to content

Push Notifications

Step 1: Enable push capabilities

Inside Xcode, navigate to the “Capabilities” tab of your app. You will need to enable “Push Notifications”.

capabilities

Step 2: Generating a Certificate Request

  • Launch the “Keychain Access” app on your Mac.

  • Select “Keychain Access> Certificate Assistant> Request a Certificate From a Certificate Authority”.

keychain_request

  • Enter your e-mail, select “Save to disk” and press “Continue”. You should get a .certSigningRequest file.

save_request

Step 3: Get the Certificate

  • Visit your developer.apple.com account page, select the Identifiers section and select your app. Inside the page, enable Push Notification capabilities.

edit_app

  • Go to the app page again and click on Configure next to the Push Notification capability. On the dialog, Press Create Certificate for the Production SSL Certificate (When you create a production certificate for push notification you can use it for both the sandbox and production environments).

enable_push

  • Press “Choose File” to upload the .certSigningRequest file you generated previously and press Continue

add_certificate

  • Your certificate is ready. Press “Download” to get the .cer file.

get_certificate

Step 4: Upload a .p12 Key to NearIT

  • Click on the .cer certificate you generated previously (chapter 3.5). It will open the “Keychain Access” app on your mac.

  • Find your certificate, click on it and select “Export”. Enter a password, you will get a .p12 file.

export_p12

  • Open NearIT web interface, select your app and navigate to “Settings> Push Settings”. Upload your .p12 under the “Setup iOS push notifications” block. You will be prompted to enter the password you have chosen previously

export_p12

Step 5: Get the device token and push callbacks

In your AppCelerator Titanium app, register for push notifications:

Ti.Network.registerForPushNotifications({
  success: function(token) {
    // You got the push token, give it to the SDK
    NearIT.registerForPushNotifications(token.deviceToken);
  },
  error: function(e) {
    console.log("registerForPushNotifications", e);
  },
  callback: function(pushNotification) {
    // Push received, give it to the SDK
    NearIT.didReceiveRemoteNotification(pushNotification);
    }
});

To test that everything went ok, you should enroll your device as a Test Device and send it a test push from the “Settings> Push Settings” section.

The app is now able to receive push notifications from NearIT.