Configure your application to receive Push Notifications
Mobile Suite enables customers to setup the application to receive Push Notifications.
To prepare your Mobile Project, do the following steps:
1. Create or reuse an application on Mobile Administrator
Your Mobile Project is now prepared to receive Push Notifications. However, depending on the target platform, there are still some steps required. Your project requires a unique ID representing the device and the application. This ID depends on the target platform and requires different prerequisites.
For Android:
Android applications using Google Messaging Services (GCM) to send Push Notifications. To register your device, you need a unique sender ID. The sender ID is a project number you will get from Android’s development console:
2. Create or use a Project and copy the Project Number from the project’s overview. It must consist of 12 numbers.
3. Enable Cloud Messaging for Android in the APIs & Auth section.
4. Create a new API key for public API access.
5. Open your application in Mobile Administrator, select Manage App and go to Push. There you need to enter the API key as the GCM API Key.
6. Open your Mobile Project with the Mobile Development perspective.
7. Open the targets/_defaults_.xml file.
8. Add the following properties:
Property | Description |
<property name=”android.push.sender.id” value=”yourProjectNumber”/> | Required. This property represents the sender ID. It’s the project number you’ll get from the development console. |
<property name=”android.push.additional.icon” value=”resources/icons/myIcon.png”/> | Optional. Specify an icon to display for the notification item within the status bar. |
<property name=”android.push.additional.icon.pre21api” value=”resources/icons/myIcon.png”/> | Optional. Specify an icon to display for the notification item within the status bar. This icon will be used for devices with Android up to API 20. |
For iOS:
iOS applications using the Apple Push Notification Service (APNS). You need to setup a SSL Certificate for your App ID and configure a provisioning profile with Push Notifications enabled and build/rebuild your application:
1. Open your application in Mobile Administrator, select Manage App and go to Push.
a. Select Add Certificate (Production).
b. Create a Certificate Signing Request (CSR).
c. Download the Certificate Signing Request (CSR) to be used in the following steps.
a. Select Identifiers.
b. Create a new App ID with Push Notifications enabled.
c. Edit the App ID and look for Push Notifications. There you can add production and development SSL certificates needed to send Push Notifications via APNS.
d. Select Create Certificate.
e. Continue by providing the CSR file downloaded from Mobile Administrator and Generate a new certificate.
3. In your Mobile Administrator application you can now upload the Certificate for the Certificate Signing Request created earlier.
4. In Apple Developer Portal you can now create or regenerate the Provisioning Profile for your app and download.
5. Add the Provisioning Profile to Mobile Administrator.
6. Edit your iOS build configuration and check the Register for Push Notifications App Policy.
7. Rebuild the application using the new Provisioning Profile. Mobile Administrator enriches the application with code to do the registration to APNS and sends the registration ID back to Mobile Administrator.
For Windows:
No additional steps are required to prepare a Windows application.
Once your registration to the platforms Push Notification service is completed, you need to publish the registration ID to
Mobile Administrator. This work is required for Android and Windows applications. iOS applications will automatically upload the registration ID to
Mobile Administrator, if the
Register for Push Notification App Policy is checked in your build configuration. To upload the registration ID to
Mobile Administrator, open your
Application Controller in
Software AG Designer and overwrite the
onDeviceRegistered(). For more information see
Common Methods to Override in the Generated
Code for the Application. Have a look at the following snippet:
public void onDeviceRegistered(final String newPushUID) {
final PostPushRegister request = new
PostPushRegister(Parameters.PARAM_MOBILE_ADMIN_IDENTIFIER);
if(runningOnAndroid()) {
request.execute((String) null,
Parameters.PARAM_MOBILE_ADMIN_IDENTIFIER, newPushUID,
null, null);
} else if(runningOnWin8() || runningOnWinPhone()) {
request.execute((String) null,
Parameters.PARAM_MOBILE_ADMIN_IDENTIFIER, null, null,
newPushUID);
}
}
The snippet uses the built-in
PostPushRegister service. Have a look at
Adding Mobile Administrator Services for more details. After uploading the registration ID to
Mobile Administrator, you can send a Push Notification using
Mobile Administrator. Open your application in
Mobile Administrator, select
Manage App and go to
Push. Then type a text and trigger
Send Push Notification. The message will then be forwarded as a Push Notification for all registered devices.