Enable Push Notifications in Your Branded MDK Client
Use the SAP Mobile Services to enable push notifications in your branded MDK client.
Overview
You will learn
- How to set up push notifications on an Apple Developer and Google Firebase account
- How to configure push settings on SAP Mobile Services
- How to send push notification in your branded MDK client
Prerequisites
Prerequisites
- Tutorial: Set Up Initial Configuration for an MDK App
- Tutorial: Follow steps 2-6 in Enable Push Notifications in the MDK Public Store Client to create an MDK metadata project
- Tutorial: Follow steps 1-3 in Build Your mobile development kit Client Using MDK SDK to create your local MDK project
- Apple ID: A paid Apple developer account is required.
Steps
Make sure you are choosing the right device platform tab above.
Open the Firebase console, login with your Google account and click Create a new Firebase Project.

MDK Provide a Project Name, click Continue.

MDK Uncheck Enable Gemini in Firebase option and click Continue.

MDK Uncheck Enable Google Analytics for this project option and click Create Project.

MDK Once the project is ready, click Continue.

MDK Click Add app and click Android icon to add Firebase to your Android app.

MDK Provide a unique name to Android package name, click Register app.

MDK Download goole-services.jsonfile, click Next.
MDK In Add Firebase SDK step, click Next.
In the following step, click Next and then click Continue to console.

MDK Go to the Project settings.

MDK Select the Service accounts tab and click on the Generate new private key.

MDK Click the Generate key in the pop-up window and store the downloaded private key file securely because the key cannot be recovered if lost.

MDK
In order to implement Push Notifications, a paid Apple developer account is required. Students or other developers with a personal Apple ID for their team will not be able to use push notifications, because they will not have access to the Developer Portal to generate the required certificate.
To enable your app for push notifications, you need to carry out the following tasks:
- Obtain a certificate signing request
- Create a new development certificate
.cerfile - Install the
.cerfile and create the .p12 file - Register an iOS App ID
- Register your device
Obtain a certificate signing request
In order to use the Apple Push Notification service, you need to create a CSR file.
On your Mac, open the Keychain Access application, and navigate to Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority…

MDK In the dialog, enter the email address which is associated with your Apple Developer account. Also, make sure you check the Request is saved to disk option.

MDK Click Continue.
Choose a folder to store the certificate – it is good practice to store generated files in a separate folder for each project – and click Save.
Once you see a dialog saying the certificate is saved successfully, click Done to finish.

MDK Create a new development certificate
.cerfileGo to your Apple Developer Account and Click Certificates.

MDK Click + icon to register a unique Identifiers for your application.

MDK Select App IDs and click Continue.

MDK Provide a unique Bundle ID name and Description.

MDK Scroll down and select the Push Notifications capability from the list, click Continue.

MDK In the following screen, select option for Deployment Details and then click Continue.
Confirm your App ID by clicking on Register.
Create a new development certificate
.cerfileUnder Identifiers, search for the App ID that you registered in previous step.

MDK Scroll down and select the Push Notifications capability, click Configure.

MDK To configure push notifications for the provided App ID, a Client SSL Certificate is required that will allow the notification server to connect to the Apple Push Notification Service. Each App ID requires its own Client SSL Certificate.
Click Create Certificate to start the process for creating the needed
.cerfile.
MDK Click Choose File and browse to the downloaded Signing Request
CSRfile, click Continue.Apple will now create a
.cerfile for you which is issued by the Apple Worldwide Developer Relations Certification Authority.
MDK Click Download to download your certificate.

MDK Install the
.cerfile and create the .p12 fileIn order to configure the
APNSon SAP Mobile Services, you need to install the.cerfile and create the needed.p12file.A
.p12file is a encrypted container for the certificate and private key. This file is needed by Mobile Services for theAPNSconfiguration.Locate your downloaded
.cerfile and double-click it in order to install the certificate.In case the Add Certificate dialog pops up make sure to choose Login from the dropdown and click Add.
If the certificate is added correctly to the Keychain you should see it in the
MyCertificatessection, make sure you selected login as keychain.
MDK Select the certificate as well as the private key and right-click to export those two items.

MDK Make sure that in the dropdown Personal Information Exchange (.p12) is selected and click Save. You will be prompted to enter a password, click OK to export the files.

MDK Register your device
Click + icon to register your iOS device.

MDK Provide Device Name & Device ID (UDID) and then click Continue.

MDK
Make sure you are choosing the right device platform tab above.
In Mobile Services admin UI, navigate to
Mobile Applications|Native/MDK|myapp.mdk.demo|Push Notification.If you have selected Predefined for option, switch to the empty value. You should see Android option showing up on the page. Click Browseโฆ to load the downloaded private key file.

MDK You should see the values showing up, click Save to save the changes.

MDK
In Mobile Services admin UI, navigate to
Mobile Applications|Native/MDK|myapp.mdk.demo|Push Notification.If you have selected Predefined for option, switch to the empty value. You should see options showing up on the page. Provide the following details to the Apple panel and click Save.
Field Name Value APNS Endpoint Select Sandboxfrom the dropdownAuthenticate Choose CertificateCertificate Browse to the.p12certificate you just exportedPassword Enter the password you provided during the export 
MDK
You have now successfully configured the APNS Endpoint on the server side in Mobile Services admin UI.
Make sure you are choosing the right device platform tab above.
Paste the downloaded google-services.json file to /DemoSampleApp.mdkproject/App_Resources/Android/ path.

Create a new file named as
app.entitlementsand place it under/DemoSampleApp.mdkproject/App_Resources_Merge/iOS/path.
MDK Open this file and copy & paste the below information:
XML<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>aps-environment</key> <string>development</string> </dict> </plist>Assign a value of development or production to aps-environment key, depending only on which activity you are creating the provisioning profile for.
Follow step 4 from Build Your mobile development kit Client Using MDK SDK tutorial to create your branded MDK client.
Make sure you are choosing the right device platform tab above.
Follow step 5 from Build Your mobile development kit Client Using MDK SDK tutorial to create your branded MDK client.
Once you accept the App update, a message should show Push Notification registered. Click OK.

MDK It is time now to send the first push notification from the SAP Mobile Services push notification feature.
Navigate to Mobile Services admin UI. In Push Notification feature, switch to Push Registrations tab.
There you will find information about user registered for push notification and also details about Push providers. Identify your Device ID and click Send Notification.

MDK In notification dialog, type a notification message and click Send.

MDK You will see a success toast message.

MDK After sending notification, mobile device should receive the message. This example uses the simplest notification that only contains the alert property.

MDK
Follow step 5 from Build Your mobile development kit Client Using MDK SDK tutorial to create your branded MDK client.
After accepting the app update, allow the permission to display notifications. If push registration is successful, a message should show Push Notification registered. Click OK.

MDK 
MDK It is time now to send the first push notification from the SAP Mobile Services push notification feature.
Navigate to Mobile Services admin UI. In Push Notification feature, switch to Push Registrations tab.
There you will find information about user registered for push notification and also details about Push providers. Identify your Device ID and click Send Notification.

MDK In notification dialog, type a notification message and click Send.

MDK You will see a success toast message.

MDK After sending notification, mobile device should receive the message. This example uses the simplest notification that only contains the alert property.

MDK If you have Apple watch connected to the iPhone device, you can also see same push notification on the Apple Watch.

MDK MDK supports rich push notification. MDK does not run on smart watches or as an Apple watch application.
Make sure you are choosing the right device platform tab above.
Based on the device Operating System, notifications are handled differently. On Android, the notification is a data message and only handled by the apps notification callback. The callback is only called when the app is active. So, how can you make it visible always? You use the advanced Message properties:
gcm.title/gcm.bodyfor your message. For more information on Google/Firebase Cloud Messaging, see documentation.Send the Android client in the background or swipe close.
Switch to the Advanced tab, provide below payload and click Send.
JSON{ "alert": "Alert message", "gcm": { "title": "MDK Push", "body": "This is an advanced notification message" } }
MDK After sending notification, you will see a notification in the notification center.

MDK
Based on the device Operating System, notifications are handled differently. On
iOSoriPadOSthe notification is handled by the app when in foreground, but handled (and displayed) by the Notification Console and shown in the Lock Screen, when the app is in background. So, how can you make it visible always? You use the advanced Message properties:apns.title/apns.bodyfor your message. For more information on Apple Remote Notification, see documentation.Send the iOS client in the background or swipe close.
Switch to the Advanced tab, provide below payload and click Send.
JSON{ "alert": "Alert message", "apns": { "title": "MDK Push", "body": "This is an advanced notification message" } }
MDK After sending notification, you will see a notification in the notification center.

MDK
Congratulations, you have successfully enabled push notification in your branded client and you can continue with the remaining tutorials in this mission.
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.