How to Send Push Notification Android Mobile Apps from Mesosfer Backend as a Service

This tutorial is about How to Send Push Notification Android Mobile Apps from Mesosfer Backend as a Service.

Introduction

This Tutorial is the last session of Android Mobile Apps series.In this tutorial you will be required some dependency source code you created in the previous session. In this session, we’ll create module to send push notification Android Mobile Apps from Mesosfer Backend as a Service.

Getting Started

In this session we will create a simple push notifications that will be delivered to the mobile android. The Mesosfer Android SDK chooses a reasonable default configuration so that you do not have to worry about GCM registration ids, sender ids, or API keys. In particular, the SDK will automatically register your app for push at startup time using the mesosphere’s sender ID (523325046971) and the resulting registration will store the ID in the deviceToken field of the app’s current MesosferInstallation.

To be able to receive push notifications from Mesosfer Backend, you have to do some configurations. First, add the Mesosfer.SetPushNotification to the class MesosferApp.

PHP

1

Mesosfer.setPushNotification(true);

Go to AndroidManifest.xml, add some permissions.

PHP

1

2

3

4

5

<permission

android:protectionLevel="signature"

android:name="com.eyro.mesosfer.sample.permission.C2D_MESSAGE"/>

<uses-permission

android:name="com.eyro.mesosfer.sample.permission.C2D_MESSAGE"/>

Then add receiver in the tag application.

PHP

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<receiver android:name="com.eyro.mesosfer.PushBroadcastReceiver"

android:exported="false">

<intent-filter>

<action android:name="com.eyro.mesosfer.push.intent.RECEIVE"/>

<action android:name="com.eyro.mesosfer.push.intent.DELETE"/>

<action android:name="com.eyro.mesosfer.push.intent.OPEN"/>

</intent-filter>

</receiver>

<receiver android:name="com.eyro.mesosfer.GcmBroadcastReceiver"

android:permission="com.google.android.c2dm.permission.SEND">

<intent-filter>

<action android:name="com.google.android.c2dm.intent.RECEIVE"/>

<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>

<!--

IMPORTANT:Change"com.eyro.mesosfer.sample"tomatch your app's

packagename.

-->

<category android:name="com.eyro.mesosfer.sample"/>

</intent-filter>

</receiver>

Reinstall your apps and then you will see that your data installation is added.

For the next, we will try to deliver push to the user with apps you just made installed. Go to menu push and insert message you want to show.

Conclusion

We have created module to send push notification from Mesosfer Bucket. Very simple and quick, isn’t it? You do not have to worry about GCM registration ids, sender ids, or API keys, All of them have been handled by Mesosfer. Mesosfer helps you connect your project to the cloud. Cut off the development process so you can straight into the delivery process instead stumble on the complicated infrastructure.