简体   繁体   English

从Firebase通知控制台发送时未收到FCM通知

[英]FCM notification is not received when sent from firebase notification console

I am using Firebase notifications in my application. 我在应用程序中使用Firebase通知。 I have performed all steps mentioned in firebase documentaton. 我已经执行了Firebase文档中提到的所有步骤。 I can also receive the registration token inside onTokenRefresh() method. 我还可以在onTokenRefresh()方法中接收注册令牌。 But when I try to send message to my device from Firebase Notification console, It shows status as 'Completed' next to message, but I don't receive anything on my device even when app is in background. 但是,当我尝试从Firebase通知控制台向我的设备发送消息时,它在消息旁边显示为“已完成”状态,但是即使应用程序在后台,我也无法在设备上收到任何信息。

(copy paste from my other answer ) (从其他答案中复制粘贴)

I had this exact problem, the device behavior was somehow weird. 我遇到了这个确切的问题,设备的行为有点奇怪。 some notifications were received, some not. 收到了一些通知,有些则没有。

In the end I found out what was wrong. 最后,我发现了问题所在。 My device's Sync setting was off. 我的设备的同步设置已关闭。 please check that first and don't waste your time like me. 请先检查一下,不要像我一样浪费时间。 在此处输入图片说明

You need to call private void sendNotification(String topic); 您需要调用private void sendNotification(String topic); method from Overriden method public void onMessageReceived(RemoteMessage remoteMessage). 重写方法中的方法public void onMessageReceived(RemoteMessage remoteMessage)。 then your notification will added to notification bar. 然后您的通知将添加到通知栏。

Happy Coding. 编码愉快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM