FCM 通知在发布应用程序中不起作用

mr.*_*oot 4 android push-notification google-play firebase firebase-cloud-messaging

我正在尝试在未接收的发布应用程序中发送FCM通知(在用户之间发送消息、好友请求等),但它们在调试 apk 中发送/接收得很好,我对此进行了搜索,发现了一些不起作用的解决方案为我

像这样,我把它放在亲卫规则中但不起作用

 -keep class com.google.firebase.* {*;}
Run Code Online (Sandbox Code Playgroud)

在我的 AndroidManifest.xml 中

        <service
            android:name=".notifications.MyFirebaseMessaging"
            android:enabled="true"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <service
            android:name=".notifications.MyFirebaseInstanceId"
            android:enabled="true"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>
Run Code Online (Sandbox Code Playgroud)

和其他依赖项,我不将它们包含在这里,因为应用程序在调试模式下工作正常

已编辑

我已经有了

  1. 生成的发布 SHA-1 和 SHA-256 密钥
  2. 将它们添加到 firebase 控制台中
  3. 还在 firebase 中添加了 Google 控制台应用程序签名 SHA-1 和 SHA-256 密钥
  4. 然后下载 Google-services.json 文件并将其添加到应用程序模块中

在此输入图像描述 在此输入图像描述

Stu*_*eka 8

您尚未将用于发布的 SHA-1 密钥添加到您的 firebase 控制台,因此不存在于您的 google-services.json 中。

  1. 生成用于发布的 SHA-1
  2. 将您的版本 SHA-1 添加到 firebase 控制台
  3. 下载并使用新的 google-services.json。

如果您使用的是 Google Play 应用签名。确保 Play 商店用于签署您的版本的密钥也已在步骤 2 中添加