android - Firebase notification onMessageReceived show the same notification as when app in background -


i sending messages app console , managed have app react want, when in background. there notification shown sdk , when user taps , app starts, have custom data fields use build dialog message.

since want app react when on foreground i've added service , i've noticed remotemessage contains getnotification() method returns remotemessage.notification suppose used sdk show notification when app in background.

is there easy way use retrieved notification , display it, when app in background?

there sure is. override firebasemessagingservice.onmessagereceived , notification body in example firebase cloud messaging documentation:

@override public void onmessagereceived(remotemessage remotemessage) {     // todo(developer): handle fcm messages here.     // if application in foreground handle both data , notification messages here.     // if intend on generating own notifications result of received fcm     // message, here should initiated. see sendnotification method below.     log.d(tag, "from: " + remotemessage.getfrom());     log.d(tag, "notification message body: " + remotemessage.getnotification().getbody()); } 

see firebase cloud messaging documentation receiving downstream messages on android under "override onmessagereceived".


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -