首页 > 解决方案 > 应用程序被杀死时无法接收推送解析 FCM

问题描述

我已经更新了 parse sdk,这迫使我从 GCM 迁移到 FCM。我已经关注了这个链接: https ://github.com/codepath/android_guides/wiki/Push-Notifications-Setup-for-Parse

当应用程序正在运行或处于后台时,我能够收到推送通知,但在应用程序被终止时不能。

这是我的 AndroidManifest.xml :

<service
            android:name="com.parse.fcm.ParseFirebaseInstanceIdService"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <service
            android:name="com.parse.fcm.ParseFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <receiver
            android:name=".receiver.CustomParsePushReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.RECEIVE_BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
                <action android:name="com.parse.push.intent.RECEIVE" />
                <action android:name="com.parse.push.intent.OPEN" />
                <action android:name="com.parse.push.intent.DELETE" />
            </intent-filter>
        </receiver>

CustomParsePushReceiver.java

public class CustomParsePushReceiver extends ParsePushBroadcastReceiver {



    @Override
    protected void onPushReceive(Context context, Intent intent) {

        Log.e("ParsePushReceiver","Parse receiver received notification");

    }



}

我已将解析服务器、解析 sdk、parse-fcm、firebase-core 和 firebase-messaging 更新到最新版本。

标签: androidfirebaseparsingpush-notificationfirebase-cloud-messaging

解决方案


当应用程序被终止时,一些股票 ROM 会终止所有后台进程。因此推送服务被终止,当应用程序被终止时我无法接收推送。其中一些制造商是 OnePlus、联想、小米、Oppo 和 Vivo。但是当我在 HTC 和三星等其他设备上进行测试时,它工作了!!!

有关更多信息,请阅读此博客:https ://medium.freecodecamp.org/why-your-push-notifications-never-see-the-light-of-day-3fa297520793


推荐阅读