Skip to end of metadata
Go to start of metadata

To send push notifications, Mobile Backend Services (MBS) relies on the Firebase Cloud Messaging (FCM) for Android applications, and the Apple Push Notification (APN) service for iOS applications. Firebase Cloud Messaging (FCM) is the new version of Google Cloud Messaging (GCM). To use these services in your Titanium application, you first need to enable either GCM or FCM or APN for your application, and then configure MBS with information about your push service. This guide walks you through the process of creating and configuring push services for your application.

Configuring push services for iOS devices

To enable Apple Push Notification service for your application, you need to create an Apple Push Notification certificate and upload the certificate to the MBS server. Note that iOS simulators cannot receive Apple push notifications.

Create and Upload a Push Notification Certificate

To create an Apple Push Notification certificate, you need to first create an Explicit App ID. The App ID identifies where to send the push notification, which is tied to the certificate when you create it. After you create the certificate, export the certificate to PKCS #12 format and upload it to the MBS server. This certificate allows the MBS server to communicate with the Apple Push Notification server.

Register an App ID

You first need to register an App ID for your application. 

  1. Log in to the Apple Developer Member Center as the Team Agent or Admin.
  2. Click Certificates, Identifiers & Profiles.
  3. Click Identifiers, then click the add (+) button near the top-right corner.
  4. Under App ID Description, enter a value in the Name field.
  5. Select the App ID Prefix to use. (You cannot use a Wildcard App ID for an application with push notifications.)
  6. In the the App ID Suffix section, select Explicit App ID and enter your application's ID.

    Icon

    This is the value of the <id> element in your project's tiapp.xml file.

  7. Under App Services, check the Push Notifications checkbox.
  8. Click ContinueSubmit, and Done to complete the process.

The next step is to generate a certificate that approves your application for the Apple Push Notification service.

Generate an Apple Push Notification Certificate

These directions cover how to generate an Apple Push Notification certificate for both testing (Development) and production (Distribution). Only step #4 differs based on which certificate you create.

  1. Log in to the Apple Developer Member Center as the Team Agent or Admin.
  2. Click Certificates, Identifiers & Profiles.
  3. Click Certificates, then click the add (+) button near the top-right corner.
  4. For application in development, select Apple Push Notification service SSL (Sandbox). For production applications,  select Apple Push Notification service SSL (Production), then click Continue.
  5. Select the App ID that you created previously from the drop-down list, then click Continue.
  6. Follow the instructions provided for creating a Certificate Signing Request (CSR). Click Continue once you've created the CSR.
  7. Locate the CSR you created and click Generate.  You are returned to the Certificates page with the status listed as Pending. Wait a moment then  refresh the page in your browser. If asked to approve the request, click Approve.
  8. Click Download to download the certificate (.cer) file to your computer.
  9. Double-click the file to install it into your keychain.

Now that you've created the push notification certificate, you need to export it in a format that you provide API Builder.

Export the Certificate

Once you've created the certificate, you need to export it in a format that you can provide to API Builder.

  1. Open Keychain Access (Applications > Utilities > Keychain Access).
  2. Under Categories in the the left side navigation, click My Certificates.
  3. Select the certificate you installed previously and select File > Export Items....
  4. Select Personal Information Exchange (.p12) from the File Format menu and click  Save.
  5. Enter a password for the certificate, then click Save

Keychain exports your certificate as a PKCS #12 file that you upload to MBS to enable Apple Push Notification for your application.

Upload certificate to Dashboard

You use Dashboard to upload the .p12 certificate file to API Builder and enable notifications within your application.

To upload the certificate using Dashboard:

  1. Open Dashboard and select your MBS application from the Apps drop-down menu.
  2. Select Push Notifications on the left-side navigation.
  3. Select the iOS Push tab.
  4. Click Choose File,  locate the .p12 file you exported previously, and click Open.
  5. In the Certificate Password field enter the password you selected when you generated the certificate.
  6. Click Save Changes. If the password you entered was incorrect, an error dialog will alert you.

Configuring push services for Android devices

To enable push services for your Android application, you need to create a Google API project and enable its GSM service, and obtain a send.

Creating a Google API Console project and client ID

Before you can integrate Google Sign-In into your website, you must have a Google API Console project. In the project, you create a client ID, which you need to call the sign-in API.

To create a Google API Console project and client ID, follow these steps:

  1. Go to the Google API Console.
  2. From the project drop-down, select an existing project, or create a new one by selecting Create a new project.

    Icon

    Use a single project to hold all platform instances of your app (Android, iOS, web, etc.), each with a different Client ID.

  3. In the sidebar under "API Manager", select Credentials, then select the OAuth consent screen tab.
    1. Choose an Email Address, specify a Product Name, and press Save.
  4. In the Credentials tab, select the New credentials drop-down list, and choose OAuth client ID.
  5. Under Application type, select Web application. Register the origins from which your app is allowed to access the Google APIs, as follows. An origin is a unique combination of protocol, hostname, and port.
    1. In the Authorized JavaScript origins field, enter the origin for your app. You can enter multiple origins to allow for your app to run on different protocols, domains, or subdomains. You cannot use wildcards. In the example below, the second URL could be a production URL.

    2. The Authorized redirect URI field does not require a value. Redirect URIs are not used with JavaScript APIs.
    3. Press the Create button.
  6. From the resulting OAuth client dialog box, copy the Client ID . The Client ID lets your app access enabled Google APIs.

Source: https://developers.google.com/identity/sign-in/web/devconsole-project

Configuring API Builder application for FCM or GCM service

Once you've created a Google API project with FCM or GCM enabled, you need to update your application's settings page in Dashboard with the API key and sender ID you generated.

To configure API Builder for push notifications using Dashboard:

  1. Open Dashboard and select your application from the Apps drop-down menu.
  2. Click Push Notifications on the left-side navigation.
  3. Select the Android Cloud Messaging tab.
  4. Enter the server key in the Server Key field and the sender ID in the Sender ID field. To find your Server Key and Sender ID, go to Firebase. From there, click on Settings (cog) > Cloud Messaging. This page will show your Sender ID (should be the same as your project number) and your Server Key.
  5. Click Save Changes.

Note: If you are still seeing the following error message when pushing a notification, uninstall the app and rebuild it: