Skip to Content
test
0 %
Send Notifications to Your Android Application
Details
// Explore More Tutorials

Send Notifications to Your Android Application

Add foreground and background notifications to your application with help of Google Firebase.

You will learn

  • How to configure SAP Cloud Platform for push
  • How to configure Mobile Services for push
  • Foreground notifications
  • Background notifications


Step 1: Configure the SAP Cloud Platform for push notifications

Open SAP Cloud Platform Trial and log in to Neo Trial.

Neo Trial button

Select Services, then choose Mobile from the dropdown. Then click on Mobile Services, std.

Mobile Services

Click on the Configure Mobile Services link.

Configure Mobile Services

On the Roles tab, select the Notification User role and click the Assign button, assigning your User ID.

Setting Notification User role
Which role is required to send a push message?
×
Step 2: Configure Mobile Services for push notifications

Return to the Mobile Services screen.

Back to mobile services

Click the Go to Service link.

Go to Service link

In SAP Cloud Platform Mobile Services, select the application com.sap.wizapp and click on Push Notification.

Push notification link on home page

This screen requires information from the Firebase console.

Push notification

In the Firebase console, go to the Project settings

Project settings

Select the Cloud Messaging tab and copy the Server Key and Sender ID values from Firebase to the SAP Mobile Services Android Push Notification settings screen.

Server key and Sender IDPush notification android
In the cockpit, which properties are needed to enable Android push messaging in the Push Notification tab?
×
Step 3: Send a notification

Under Mobile Applications, select the application.

Management cockpit

Select the User Registrations tab to send the notification to your app.

Send notification

Note: It may be difficult to tell which registration to choose. The Last Connection field shows the last time a given registration made a request. If you are unsure which registration to choose, click through a few screens in the application and then press the GO button to refresh the display or select all of them and send a greeting to all the registrations.

Specify the notification text to send to the app.

Send notification
Log on to answer question
Step 4: Foreground notification

Notice that the app shows the notification.

Receive notification
Log on to answer question
Step 5: Background notification

On the emulator or mobile device, open another app, such as Chrome, which will cause the Wiz App to no longer be the foreground app.

If you now send another notification you notice that since the app is in the background, or not running, a notification is placed in the notification drawer.

Receive Notification Background

Tapping on the notification will bring the app to the foreground or open the app.

Receive Notification from Background

Currently, the message is displayed in an AlertDialog.

Custom logic could be added to the app to decide on the action to take, such as displaying the new Office Furniture category.

Show Notification Code

Note: Further information on push can be found at Push Notifications, Push API Notification Scenarios, and About FCM Messages.

Congratulations! You have seen how an app can make use of foreground and background notifications.

Log on to answer question

Next Steps

Back to top