[英]Why Android is not receiving FCM push notification?
I am working on an Android project and trying to receive Push Notifications using FCM. 我正在开发一个Android项目,并尝试使用FCM接收推送通知。 I implemented everything just like it is described here , on official documentation of FCM. 我实现了,就像它被描述的一切在这里 ,对FCM的官方文件。
I tested my work by sending demo notification from Firebase console and it worked. 我通过从Firebase控制台发送演示通知来测试我的工作,并且工作正常。 I used web key in my Django website and it sends notification to FCM servers and my Android app receives is properly. 我在Django网站中使用了Web密钥,它会将通知发送到FCM服务器,而我的Android应用程序接收正确。 But there is a problem with that. 但这是有问题的。 App only receives notification when it is connected to Android Studio and debug app is installed and running. 应用仅在连接到Android Studio且已安装并运行调试应用时才会收到通知。 If I exit from debug app and try, it doesn't receive it. 如果我从调试应用程序退出并尝试,则不会收到它。 I changed priority
to hight
, added content_available
= true
but still not working properly. 我将priority
更改为hight
,添加了content_available
= true
但仍无法正常工作。
I checked the error log in Android Studio and found this, 我在Android Studio中检查了错误日志,发现了这一点,
W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.app.android (has extras) }
I think GCM is playing part in the scene, and I don't know what to do to solve this error because I am not working with GCM code at all as everything is migrated to FCM. 我认为GCM在其中扮演着重要角色,而且我不知道该怎么做才能解决此错误,因为由于所有内容都已迁移到FCM,所以我根本不使用GCM代码。 Can anyone tell me what else I need to do to start receiving push notification when my device is not connected with Android Studio and debug app is not running? 当我的设备未与Android Studio连接且调试应用未运行时,有人可以告诉我要开始接收推送通知时还需要做什么吗?
NOTE: My django code works fine and I see success message in response from FCM server. 注意:我的django代码可以正常工作,并且在FCM服务器的响应中看到成功消息。
Thanks. 谢谢。
add this to service manifest : 将此添加到服务清单:
android:enabled="true"
android:exported="true">
just like this : 像这样 :
<service
android:name=".firebase.MyFirebaseMessagingService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".firebase.MyFirebaseInstanceIDService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.