Skip to main content
Version: 3.x.x

Push Notification

Configure

Check that you have google-services.json file in the root directory of your project. If you need that ask your manager.

Please, add the next permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

Then, please, add the metadata:

<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/logo_101xp2" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/transparent" />

Add the plugin to the build.gradle (root-level) file:

apply plugin: 'com.google.gms.google-services'

Add the dependency to the build.gradle (root-level) file:

dependencies {
compile 'com.google.firebase:firebase-core:16.0.7'
}

Add services:

<service
android:name="com.platform101xp.sdk.internal.services.Platform101XPMessagingService"
android:exported="true" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

Usage

To receive data from push notifications, use the Platform101XPListener method:

// Java
void onMessageReceived(Platform101XPMessage message) {
}

// Kotlin
override fun onMessageReceived(message: Platform101XPMessage?) {
}

Platform101XPMessage has getters:

getMessageId() - the message ID

getMessageBody() - the text message

getMessageSentTime() - the time of message sending