-
Notifications
You must be signed in to change notification settings - Fork 0
Gravitum Push Android
Push notifications are an easy way for developers and marketers to send short, real-time, messages to users with announcements, news, or events. They are a feature built into mobile devices, web browsers, and operating systems. If you are here, you are interested in push notifications for Android mobile platform.
Let's start the push notifications setup with providing all required AndroidManifest.xml tags for Gravitum SDK. You have to add two Gravitum services and one receiver in your main AndroidMaifest.xml file.
Important: All the {YOUR APP BUNDLE ID} places should be replaced with your own application bundle ID.
<receiver android:name="com.gravitum.messaging.CloudMessagingReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.gravitum.messaging.OPEN" />
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="{YOUR APP BUNDLE ID}" />
</intent-filter>
</receiver>
<service android:name="com.gravitum.messaging.CloudMessagingService" android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service android:name="com.gravitum.messaging.CloudRegistrationService" android:exported="false">
</service>The permissions required by Gravitum are listed below
<permission android:name="{YOUR APP BUNDLE ID}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="{YOUR APP BUNDLE ID}.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />Gravitum SDK records two push message events: 1)when the notification is sent to the user and 2) when the user taps on the notification and the app will open up.
The use-case for received push listener is following:
Analytics.SetReceivedPushListener(new IReceivedPushMessageListener() {
@Override
public void onReceived(int id, String title, String subtitle, String content, boolean isAppForeground, JSONObject json) {
Log.d("Gravitum", "!!!PUSH RECEIVED!!! " + Integer.toString(id) + "|" + title + "|" + content + "|" + Boolean.toString(isAppForeground) + "|" + json.toString());
}
});