关于android:FCM返回错误:第一条消息后未注册

FCM returns error : NotRegistered after the first message

我按照firebase.google.com上的说明在项目中添加了FCM。一切都很好,我在日志中收到了消息" FirebaseApp初始化成功"和新令牌。但这不起作用...只有我发送给令牌的第一个推送通知才获得成功。第二次推送和休息得到错误" NotRegistered "。
文档说

If it is NotRegistered, you should remove the registration ID from your server database because the application was uninstalled from the device, or the client app isn't configured to receive messages.

但未删除应用程序,并且客户端应用程序被配置为接收消息,因为第一条消息到达了客户端


我奋斗了几个小时,但发现了问题。真的也很难找到和解释。我会尝试:

我的项目具有一个依赖关系,其中包含另一个依赖关系:
My project > Dependency > Sub-dependency

子依赖项包含带有标记的AndroidManifest.xml文件。像这样的东西:

1
2
3
4
5
6
7
8
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.my_sub_library">

   

    </application>

</manifest>

由于此应用程序标签,我的依赖关系需要这样做:

1
2
3
4
<manifest package="br.com.ilhasoft.support.databinding"
    xmlns:tools="http://schemas.android.com/tools">
   
</manifest>

我的解决方案是通过删除应用程序标签来更新子依赖关系,并通过删除替换操作来更新依赖关系。

不知何故,firebase忽略了我的FirebaseMessagingService并吊销了我的FCM注册令牌。

我建议您检查依赖项,以查看哪个具有应用程序标签并对其进行更新/替换。它对我有用!