public class MCSFirebaseMessagingService
extends FirebaseMessagingService
public class MyFirebaseMessagingService extends MCSFirebaseMessagingService { @Override protected void onMessage(RemoteMessage remoteMessage) { Logger.d("MyFirebaseMsg", "onMessage method invoked."); Map <String, String > map = remoteMessage.getData(); //get msg, body String title = map.get("title"); String message = map.get("body"); Intent intent = new Intent(this, MainActivity.class); super.sendMCSCustomNotification(message,title, getApplicationContext(), intent); } }And the above class must be registered in the Android application's AndroidManifest.xml <application> node as follows:
<service android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
Constructor and Description |
---|
MCSFirebaseMessagingService() |
Modifier and Type | Method and Description |
---|---|
protected void |
onMessage(RemoteMessage remoteMessage)
On OMCe Message, developer should always override this to provide a notification to user.
|
void |
onMessageReceived(RemoteMessage remoteMessage)
Called when message is received.
|
protected void |
sendMCSCustomNotification(java.lang.String messageBody,
java.lang.String tittle,
Context ctx,
Intent intent)
Create and show a simple notification containing the received FCM message.
|
public void onMessageReceived(RemoteMessage remoteMessage)
remoteMessage
- Object representing the message received from Firebase Cloud Messaging.protected void onMessage(RemoteMessage remoteMessage)
remoteMessage
- remote message object containing message detailsprotected void sendMCSCustomNotification(java.lang.String messageBody, java.lang.String tittle, Context ctx, Intent intent)
messageBody
- FCM message body receivedctx
- contextintent
- Intent