Cordova SDK integration with iOS push notification service

Attention! The support of the SDK for this platform has been suspended!

General information

To enable PUSH-notifications, please perform the following actions:

  • Add the application to your space in devtodev system
  • Generate Developer or Production Certificate for the application and get Private key file (.p12) on its basis
  • Submit the data to the application settings in devtodev system
  • Integrate devtodev SDK to the application (see the “SDK integration” division to learn more about integrating and initializing devtodev SDK)
  • Add several lines of the code to switch in the push-notification to the SDK
  • Create a campaign for sending push-notifications in “Push” section

Enabling Push Notifications and certificate generation

Enabling Push Notifications

First enable push notifications in your Xcode project.

In the Capabilities pane, if Push Notifications isn’t enabled, click the switch in the Push Notifications section.

The library provides support for iOS 10 notification attachments, such as images, animated gifs, and video. In order to take advantage of this functionality, you will need to create a notification service extension alongside your main application.​

Create a new iOS target in Xcode (File -> New -> Target) and select the Notification Service Extension type.

​In Member Center, the Push Notifications service will appear as Configurable (not Enabled) until you create a client SSL certificate.

Drag the devtodevAppExtensions.framework into your app project.

Modify your extension.

  1. Delete all dummy source code for your new extension.
  2. Inherit from DTDMediaAttachmentExtension in NotificationService.
    #import <devtodevAppExtensions/devtodevAppExtensions.h>
    @interface NotificationService : DTDMediaAttachmentExtension
    #import "NotificationService.h"
    @interface NotificationService ()


Creating a Universal Push Notification Client SSL Certificate

You use Member Center to generate a push notification client SSL certificate that allows your notification server to connect to the APNs. Each App ID is required to have its own client SSL certificate. The client SSL certificate Member Center generates is a universal certificate that allows your app to connect to both the development and production environments.

  1. In Certificates, Identifiers & Profiles, select Certificates.
  2. Click the Add button (+) in the upper-right corner.
  3. Under Production, select the “Apple Push Notification service SSL (Sandbox & Production)” checkbox, and click Continue.
  4. Choose an App ID from the App ID pop-up menu, and click Continue.
    Choose the explicit App ID that matches your bundle ID.
  5. Follow the instructions on the next webpage to create a certificate request on your Mac, and click Continue.
  6. Click Choose File.
  7. In the dialog that appears, select the certificate request file (with a .certSigningRequest extension), and click Choose.
  8. Click Generate.
  9. Click Download.

Follow these steps to export the certificate from Apple web-site to the P12-file:

  1. Open "Keychain access" application
  2. If the certificate hasn't been added to keychain access yet, choose "File" →  "Import". Find the certificate file (CER-file) provided by Apple
  3. Choose "Keys" section in "Keychain access" application
  4. Choose personal key associated with your iPhone developer certificate. Personal key is identified by open certificate associated with it "iPhone developer: ". Choose "File" → Export objects. Save key as .p12
  5. You'll be suggested to create a password which is used when you need to import the key to another computer.


Convert  the certificate from Apple web-site to the P12-file on Windows OS

Convert Apple certificate file to the PEM-file. Start following command-line operation from bin catalog OpenSSL.

openssl x509 -in developer_identity.cer -inform DER -out developer_identity.pem -outform PEM

Convert personal key from Mac OS keychain to the PEM-key:

openssl pkcs12 -nocerts -in mykey.p12 -out mykey.pem

Now you are able to create P12-file using PEM-key and iPhone developer certificate:

openssl pkcs12 -export -inkey mykey.key -in developer_identity.pem -out iphone_dev.p12

If you are using key from Mac OS keychain than choose PEM-version created at previous step.

Otherwise you can use OpenSSL key for Windows OS.

Upload the certificate to the site

Upload the .p12-file into Integration section of application settings panel  (My apps →App Name → Settings → Integration)



SDK Integration

After the certificates has been generated you can start to integrate Push SDK into you app.

1. Open "Capabilities" tab in the XCode and switch "Background Modes" and "Push Notifications" to ON. Then check "Remote notifications"

2. Subscribe to onPushReceived and onPushOpened event

document.addEventListener('onPushReceived', this.onPushReceived, false);
document.addEventListener('onPushOpened', this.onPushOpened, false);

3. Call the method registerForPushNotification after SDK initialization

    function(token) {
        alert("[JS]onPushTokenReceived: " + token);
    function(error) {
        alert("[JS]onPushTokenError: " + error);
plugins.devtodev.init(appId, appSecret);

4. Update your app

cordova platform update ios

5. Compile and run the app. You will need a device, because simulator does not support push notifications.
Xcode will automatically choose new provisioning profile. If an error occurred during the launch make sure that there is a correct profile set in the Code Signing Identity.
You'll be asked to confirm push-notifications. An app will request permission only once, if user confirm it - notifications will be accepted otherwise he wont get any push messages from your app. User can change it in device settings.

Creating a new push-notification in devtodev interface

  1. Open PUSH tag and click on ADD NEW PUSH button.

  2. Fill in campaign name, select an app for delivery
    Attention! You can create a campaign only after at least one push token comes from devtodev SDK integrated to your application. Otherwise the app will not be displayed in the list.


  3. Choose user group to send a message. You can choose existing segment or create a new one.

  4. Enter notification details

  5. Schedule the delivery

  6. That's it!

  7. That's it!

Checking the events
Analytics Integration