我已经更新了解析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更新到最新版本。
答案 0 :(得分:0)
您需要为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>
答案 1 :(得分:0)
当该应用程序被杀死时,某些备用ROM会杀死所有后台进程。因此,推送服务被终止,当应用被终止时,我无法接收推送。其中一些制造商是OnePlus,Lenovo,Xiomi,Oppo和Vivo。但是,当我在HTC和Samsung等其他设备上进行测试时,它可以正常工作!!
有关更多信息,请阅读此博客:https://medium.freecodecamp.org/why-your-push-notifications-never-see-the-light-of-day-3fa297520793