Skip to content

Latest commit

 

History

History
257 lines (175 loc) · 17.1 KB

File metadata and controls

257 lines (175 loc) · 17.1 KB
copyright
years
2015, 2021
lastupdated 2021-03-16
keywords push notifications, push notification, notification provider credentials
subcollection mobilepush

{:external: target="_blank" .external} {:shortdesc: .shortdesc} {:codeblock: .codeblock} {:pre: .pre} {:screen: .screen} {:tsSymptoms: .tsSymptoms} {:tsCauses: .tsCauses} {:tsResolve: .tsResolve} {:tip: .tip} {:important: .important} {:note: .note} {:download: .download} {:java: .ph data-hd-programlang='java'} {:ruby: .ph data-hd-programlang='ruby'} {:c#: .ph data-hd-programlang='c#'} {:objectc: .ph data-hd-programlang='Objective C'} {:python: .ph data-hd-programlang='python'} {:javascript: .ph data-hd-programlang='javascript'} {:php: .ph data-hd-programlang='PHP'} {:swift: .ph data-hd-programlang='swift'} {:reactnative: .ph data-hd-programlang='React Native'} {:csharp: .ph data-hd-programlang='csharp'} {:ios: .ph data-hd-programlang='iOS'} {:android: .ph data-hd-programlang='Android'} {:cordova: .ph data-hd-programlang='Cordova'} {:xml: .ph data-hd-programlang='xml'}

Obtain notification service provider credentials

{: #push_step_1}

To set up {{site.data.keyword.mobilepushshort}} service, you need to obtain the required credentials from your push notification service provider.

For Android

{: #push_step_1_android}

Firebase Cloud Messaging (FCM) is the gateway that is used to deliver push notifications to Android devices, Google Chrome browser and Chrome Apps & Extensions. To set up the {{site.data.keyword.mobilepushshort}} service on the console, you need to get your FCM credentials (Sender ID and API key).

The API key is stored securely and used by the {{site.data.keyword.mobilepushshort}} service to connect to the FCM server and the sender ID (project number) is used by the Android SDK and the JS SDK for Google Chrome and Mozilla Firefox on the client side.

To set up FCM and obtain your credentials, complete the steps:

  1. Visit the Firebase Console{: external}. A Google user account is required.

  2. Click Create a project. If you are already having a project, then click Add Project.

  3. In the Create a project window, provide a project name, and accept the terms and enable or disable Google Analytics (optional) by selecting the toggle switch and click Continue.

  4. If Google Analytics is enabled, then in the Configure Google Analytics window, choose the Analytics location, and accept the terms. Click Create Project.

  5. Click Continue when the new project is ready.

  6. In the navigation pane, select the settings icon next to the Project Overview and select Settings > Project settings.

  7. Click Cloud Messaging tab to view your project credentials - Server Key and Sender ID.

    Obtaining credentials for FCM

You would also need to generate the google-services.json file. Complete the following steps:

  1. In the Firebase console Project overview section, under Get started by adding Firebase to your app section click the Android icon.

    Firebase Project overview

  2. In Add Firebase to your Android app window, first add com.ibm.mobilefirstplatform.clientsdk.android.push as the Package Name. The App nickname field is optional. Click Register APP.

    Adding Firebase to your Android window

  3. Now, include the package name of your application, by entering the package name in Add Firebase to your Android app window. The App nickname field is optional. Click Register APP. See the following example:

    Adding the package name of your application

    If you don't have any apps to start with, download the Android sample app here. {: note}

  4. The google-services.json file is generated.

Once you have obtained your FCM credentials and have generated the google-services.json file, the next step is to Configure a service instance.

Google has deprecated GCM and has integrated Cloud Messaging with Firebase. You must migrate your GCM client apps on Android to FCM. {: note}

For iOS

{: #push_step_1_ios}

For iOS devices and applications, Apple Push Notification Service (APNs) allows application developers to send remote notifications from {{site.data.keyword.mobilepushshort}} service instance on IBM Cloud (the provider) to iOS devices and applications. Messages are sent to a target application on the device.

You need to obtain and configure your APNs credentials. The APNs certificates are securely managed by {{site.data.keyword.mobilepushshort}} service and used to connect to APNs server as a provider.

Registering an App ID

{: #push_step_1_ios_2}

The App ID (the bundle identifier) is a unique identifier that identifies a specific application. Each application requires an App ID. Services like the {{site.data.keyword.mobilepushshort}} service are configured to the App ID.

Ensure that you have an Apple Developers{: external} account. This is a mandatory prerequisite. {: important}

  1. Go to the Apple Developer{: external} portal, click Member Center, and select Certificates, Identifiers & Profiles.
  2. Go to Identifiers > Add identifier button.
  3. In the Register a New Identifier page, select the AppIDs option.
  4. Provide the App name in the App ID Description Name field. For example, ACME Push Notifications.
  5. Provide a string for the App ID Prefix.
  6. For the Bundle ID, choose Explicit and provide a Bundle ID value. It is recommended that you provide a reverse domain-name style string. For example, com.ACMECloud.push
  7. Select the {{site.data.keyword.mobilepushshort}} check-box from the Capabilities and click Continue.
  8. Go through your settings and click Register > Done.

Your App ID is now registered.

Registered App ID

Create a development and distribution APNs SSL certificate - p12 or p8

{: #push_step_1_ios_3}

Before you obtain an APNs certificate, you must first generate a certificate signing request (CSR) and submit it to Apple, the certificate authority (CA). The CSR contains information that identifies your company and your public and private key that you use to sign for your Apple push notifications. Then, generate the SSL certificate on the iOS Developer Portal. The certificate, along with its public and private key, is stored in Keychain Access.

You can use APNs in two modes:

  • Sandbox mode for development and testing.
  • Production mode when distributing applications through the App Store (or other enterprise distribution mechanisms).

You must obtain separate certificates for your development and distribution environments. The certificates are associated with an App ID for the app that is the recipient of remote notifications. For production, you can create up to two certificates. IBM Cloud uses the certificates to establish an SSL connection with APNs.

p12 Certificate

  1. Go to the Apple Developer{: external} website, click Member Center, and select Certificates, Identifiers & Profiles.

  2. In the Identifiers area, select your App ID.

  3. Select the Push Notifications check-box OR select the configure option, then:

    • On Development SSL certificate pane, click Create Certificate...
    • On Production SSL certificate pane, click Create Certificate...

    Push Notification SSL certificates

  4. Use Keychain Access application on your Mac to create a Certificate Signing Request (CSR).

  5. From the menu, select Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority…

  6. In Certificate Information, enter the email address that is associated with your App Developer account and a common name. Give a meaningful name that helps you identify whether it is a certificate for development (sandbox) or distribution (production); for example, sandbox-apns-certificate or production-apns-certificate.

  7. Select Save to disk to download the .certSigningRequest file to your desktop, then click Continue.

  8. In the Save As menu option, name the .certSigningRequest file and click Save.

  9. Click Done. You now have a CSR.

  10. For the Upload CSR file option, click Choose File, and select file CertificateSigningRequest.certSigningRequest.

  11. Click Continue.

  12. On the Download, Install and Backup pane, click Download. The aps_development.cer file is downloaded.

    Download certificate

  13. Click Download to download your certificate, then click Done.

  14. On your Mac, go to Keychain Access > My Certificates, and locate your newly installed certificate. Double-click the certificate to install it into the Keychain Access.

  15. Select the certificate and private key, and then select Export to convert the certificate into the personal information exchange format (.p12 format).

    Export certificate and keys

  16. In the Save As field, provide the certificate a meaningful name. For example, sandbox_apns.p12_certifcate or production_apns.p12, then click Save.

    Export certificate and keys

  17. In the Enter a password field, enter a password to protect the exported items, then click OK. You can use this password to configure your APNs settings on the {{site.data.keyword.mobilepushshort}} service console.

    Export certificate and keys

  18. The Key Access.app prompts you to export your key from the Keychain screen. Enter your administrative password for your Mac to allow your system to export these items, and then select the Always Allow option. A .p12 certificate is generated on your desktop.

p8 Certificate

  1. In the Apple Developer portal navigate to - Certificates, Identifiers & Profiles - Left Nav

    Install p8 certificate

  2. Navigate to Keys on Left Nav.

    Install p8 certificate

  3. Enter Key Name and enable APNs, click on continue.

    Register a new key

  4. Click Register. Register p8 certificate

  • Make sure to download Keys in new redirected page after registration as it is a one time activity. {: note}

    KeyID will be visible as part of the file and displayed in the UI, this KeyID will be used for registering APNS certificate. TeamID is provided by apple for the developer account, can be seen next to the Team Name. TeamID will be used for registering APNS certificate. BundleID can be registered same as P12 certificate. {: note}

Creating a development provisioning profile

{: #create-push-credentials-dev-profile}

The provisioning profile works with the App ID to determine which devices can install and run your app and which services your app can access. For each App ID, you create two provisioning profiles: one for development and the other for distribution. Xcode uses the development provisioning profile to determine which developers are allowed to build the application and which devices are allowed to be tested on the application.

Ensure that you have registered an App ID, enabled it for {{site.data.keyword.mobilepushshort}} service, and configured it to use a development and production APNs SSL certificate.

Create a development provisioning profile, as follows:

  1. Go to the Apple Developer{: external} portal, click Member Center, and select Certificates, Identifiers & Profiles.
  2. Go to the Mac Developer Library, scroll to the Creating Development Provisioning Profiles section, and follow the instructions to create a development profile.

When you configure a development provision profile, select the following options:

  • iOS App Development
  • For iOS and watchOS apps {: note}

Creating a store distribution provisioning profile

{: #create-push-credentials-apns-distribute_profile}

Use the store provisioning profile to submit your app for distribution to the App Store.

  1. Go to the Apple Developer{: external} portal, click Member Center, and select Certificates, Identifiers & Profiles.
  2. Double-click the downloaded provisioning profile to install it into Xcode.

After obtaining the credentials, the next step is to Configure a service instance.

For web browsers and Chrome Apps & Extensions

{: #configure-credential-for-browsers}

The {{site.data.keyword.IBM_notm}} {{site.data.keyword.mobilepushshort}} service extends capabilities to send notifications to your browser and also Chrome Apps & Extensions.

The website URL or the domain name of your website is required by the {{site.data.keyword.mobilepushshort}} service to identify the requests that need to be allowed.

For example, https://www.acmebanks.com

A {{site.data.keyword.mobilepushshort}} service instance supports only one domain name at a time. Hence, ensure that the same value is set for Chrome, Firefox, and Safari. Chrome and Safari browsers require more configuration for web push. You would need an FCM API key, as an FCM endpoint is used to deliver messages in Chrome.

To set up the service for Chrome, Firefox browsers, and Chrome Apps & Extensions, see Configure a service instance.

Configuring for Safari web push

{: #configure-safari}

The supported version for {{site.data.keyword.mobilepushshort}} service on Safari is 10.0. You need to generate a certificate through your Apple Developer account before you can configure your browser to receive notifications.

Generating a certificate

{: #certificate-generation}

Ensure that you have an Apple Developer account. You need to register a website Push ID and generate a certificate to configure your Safari browser to receive notifications. The following steps help you get started:

  1. In the Apple Developer Member center, click Certificates, ID & Profiles.

  2. Click Identifiers and then Add identifier button.

  3. In the Register a New Identifier page, select the Website Push IDs option.

    Push Notifications console

  4. In the Register Website Push ID pane, provide an appropriate Website Push ID description and identifier ID. It is recommended that this is in reverse-domain name format, starting with web. For example, web.com.acmebanks.

  5. Register the Website Push ID. You now have your Website Push ID.

  6. Open the identifier and select Create certificate to create a certificate to use for the Website Push ID.

  7. Use Keychain Access application on your Mac to create a Certificate Signing Request (CSR).

  8. From the menu, select Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority…

  9. In Certificate Information, enter the email address that is associated with your App Developer account and a common name. Give a meaningful name that helps you identify whether it is a certificate for development (sandbox) or distribution (production); for example, sandbox-apns-certificate or production-apns-certificate.

  10. Select Save to disk to download the .certSigningRequest file to your desktop, then click Continue.

  11. In the Save As menu option, name the .certSigningRequest file and click Save.

  12. Click Done. You now have a CSR.

  13. For the Upload CSR file option, click Choose File, and select file CertificateSigningRequest.certSigningRequest.

  14. Click Continue. Ensure that you download the Website push certificate created in the .cer format.

  15. Open the Certificate in the KeyChain Access tool. Right-click and export as a p12 certificate. Note the password that is provided during the generation of the p12 certificate.

After generating a certificate, the next step is to Configure a service instance.