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
Post a Comment