To send push notifications, you will need to first register your app with the push notification service (Apple APNs or Google GCM) that corresponds to your app‘s platform. Once you’ve registered, the service will provide you with a certificate or key that you will need when you create an Usergrid notifier. (See Creating notifiers for more information.)
Push notification services are gateways controlled by platform services (such as Apple and Google). These gateways ensure that push notifications are delivered securely and originate from trusted apps.
To send push notifications to your app on iOS devices, you’ll register the the Apple Push Notification service (APNs). For app on Android, you’ll register with Google Cloud Messaging for Android (GCM).
Before you can send push notifications to your app on iOS devices, you‘ll need to get set up so that Apple knows you’ll be sending notifications. To do that, you'll need to do the following:
For more information see “How the pieces connect” in Setting up push notification support.
First, you'll create an SSL signing certificate that you can use to generate a .p12 certificate. To generate an SSL signing certificate, do the following:
Next, you must create an App ID for your app. The App ID uniquely identifies your app and provides a way for you to configure the app for push notification support. (For more on App IDs, see Creating and Configuring App IDs.)
Finally, you will generate the .p12 certificate using the App ID and signing certificate you created in the previous steps. The .p12 certificate will be sent by Apigee to Apple APNs with all push notification requests. A unique .p12 certificate is required for each app. In addition, you should create separate .p12 certificates for development and production versions of your app.
.. image:: pushsslcertificate.png
To create a notifier for sending notifications, you‘ll need a Google API project and register your app as part of that project. The project’s identifier (project number) will become the sender ID your client code will send when registering. Registering your app will give you an API key you'll use to create a notifier. (For more information see “How the pieces connect” in Adding push notifications support.)
The following is an abbreviated version of the steps described in the Google documentation on getting started with Google Cloud Messaging.
To generate a project number and API key, do the following:
Go to the Google API developer web site and log in with your Google ID.
Click Create Project, enter a project name and ID, then follow the steps required to verify.
In the left nav, click Overview to view the project number. Note this number for later use in client code.
.. image:: googleproj0.png
.. image:: gcmsetting.png
In the left nav, under APIs and auth, click Credentials.
Under Public API access, click Create New Key.
In the Create a new key dialog, click Server key. Take care not to choose “Android key,” though you might be tempted to. Remember that your push notification requests will be received by Google from Apigee's server (via the notifier your code sends to Apigee), rather than directly from the device your app is installed on.
On the Create a server key... dialog, enter the IP address of the server that will be sending the notification request to Google.
Click Create.
On the Credentials page, under Key for server applications, copy the API key value for use when creating a notifier to request push notifications from GCM. (For more information, see Creating notifiers.)