android - 应用程序被杀死时无法接收推送解析 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 更新到最新版本。
解决方案
当应用程序被终止时,一些股票 ROM 会终止所有后台进程。因此推送服务被终止,当应用程序被终止时我无法接收推送。其中一些制造商是 OnePlus、联想、小米、Oppo 和 Vivo。但是当我在 HTC 和三星等其他设备上进行测试时,它工作了!!!
有关更多信息,请阅读此博客:https ://medium.freecodecamp.org/why-your-push-notifications-never-see-the-light-of-day-3fa297520793
推荐阅读
- sql - Analysis Services 表格模型 - 按周分组的新计算表(使用 DAX)
- .htaccess - htaccess 重定向奇怪的 url 目标。如何解决这个问题?
- java - Unirest POST 发送无法识别的字段(io.vertx.core.json.DecodeException 错误)
- javascript - 在表单输入中显示来自对象的正确数据
- ios - 在带有 A-Frame 的 iOS chrome 71 上无法播放视频
- rest - 查询字符串和路径参数的正确格式是什么?
- html - 更改按钮字体大小也会更改 ios 上的宽度
- c# - 您如何检测在聚焦任何窗口时按下的 XButton1?
- java - 仅显示最近添加的对象的数组列表
- r - 将栅格与可分割分辨率相关联