android firebase reg id recived but notification not show in phone display -
i try show personal single notification on phone tray, can't rich, help.
i having issue firebase cloud messaging in token device , send notification test through google firebase notification console, however, notification never logged nor pushed android virtual device. documentation fcm code have below , little else in way of else have push notifications working firebase. have gone through of setup information (build.gradle additions, installing google play services, etc...) specified in documentation, still not have messages generating. wrong code not receiving push notifications logcat or device? please let me know further information helpful. thanks.
mregistrationbroadcastreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { if (intent.getaction().equals(config.registration_complete)) { firebasemessaging.getinstance().subscribetotopic(config.topic_global); displayfirebaseregid(); } else if (intent.getaction().equals(config.push_notification)) { string message = intent.getstringextra("message"); toast.maketext(getapplicationcontext(), "push notification: " + message, toast.length_long).show(); txtmessage.settext(message); } } }; displayfirebaseregid(); } private void displayfirebaseregid() { sharedpreferences pref = getapplicationcontext().getsharedpreferences(config.shared_pref, 0); string regid = pref.getstring("regid", null); log.e(tag, "firebase reg id: " + regid); if (!textutils.isempty(regid)) txtregid.settext("firebase reg id: " + regid); else txtregid.settext("firebase reg id not received yet!"); } @override protected void onresume() { super.onresume(); localbroadcastmanager.getinstance(this).registerreceiver(mregistrationbroadcastreceiver, new intentfilter(config.registration_complete)); localbroadcastmanager.getinstance(this).registerreceiver(mregistrationbroadcastreceiver, new intentfilter(config.push_notification)); notificationutils.clearnotifications(getapplicationcontext()); } @override protected void onpause() { localbroadcastmanager.getinstance(this).unregisterreceiver(mregistrationbroadcastreceiver); super.onpause(); }
and add lib of fire base messaging is:
compile 'com.google.firebase:firebase-messaging:11.0.4'
you don't need subscribe inside broadcastreceiver can inside ontokenrefresh
method in firebaseinstanceidservice
you don't need push notification in broadcastreceiver, have inside onmessagereceive
in firebasemessagingservice
fcm extremely unreliable emulators, use real device, have struggled , in cases notification days later when opening emulator other projects, test real phones
wiki
Comments
Post a Comment