小编Adh*_*hdk的帖子

Firebase云消息传递:在android 12中未收到消息

我正在尝试使用 Firebase 消息服务向Android 12 设备发送推送通知。当我尝试从nodeJs发送FCM时,不会调用onMessageReceived。我尝试从 Firebase 控制台发送 FCM,但即使应用程序位于后台,应用程序也不会显示任何通知或错误。我已经在android 11android 10中测试了这个应用程序,两者都工作正常。

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />


<application
        android:allowBackup="true"
        android:icon="@mipmap/icon"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/icon_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MobileSMSService"
        android:usesCleartextTraffic="true">

<service
        android:name=".helper.MessagingService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/sms_icon_foreground" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/purple_700" />
</service>
</application>
Run Code Online (Sandbox Code Playgroud)

消息服务.java

public class MessagingService extends FirebaseMessagingService {

    private static final String CHANNEL_ID = "FCM";
    private static final String TAG = "MessagingService";
    whatsappMessageService messageService;

    @Override
    public void onNewToken(@NonNull String s) {
        super.onNewToken(s);
        JSONObject …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-cloud-messaging

2
推荐指数
1
解决办法
8812
查看次数