【问题标题】:Cannot receive push when app is killed Parse FCM应用程序被杀死时无法接收推送解析 FCM
【发布时间】:2018-06-20 07:29:13
【问题描述】:

我更新了 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");

    }



}

我已将 parse server、parse sdk、parse-fcm、firebase-core 和 firebase-messaging 更新到最新版本。

【问题讨论】:

  • 推送消息的优先级(正常或高)。当推送通知传入时,您是否有一些 FJD 或 JobIntentService 来唤醒应用程序?还要检查firebase.google.com/docs/cloud-messaging/concept-options
  • 在 .receiver.CustomParsePushReceiver 上发布您的代码
  • 我只是登录customparsepushreceiver
  • 应用下面的答案,它会工作

标签: android firebase parsing push-notification firebase-cloud-messaging


【解决方案1】:

您需要为com.parse.ParsePushBroadcastReceiver 设置单独的接收者

将您的其他操作(如 Boot_Complete)放在单独的接收器上。

<receiver
    android:name="com.parse.ParsePushBroadcastReceiver"
    android:exported="false">
    <intent-filter>
        <action android:name="com.parse.push.intent.RECEIVE" />
        <action android:name="com.parse.push.intent.DELETE" />
        <action android:name="com.parse.push.intent.OPEN" />
    </intent-filter>
  </receiver>

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-04
      • 1970-01-01
      • 2017-12-02
      • 1970-01-01
      • 2017-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多