[英]Android app not receiving Firebase Push Notification when application is killed from multi-task tray on some devices like lenovo
I am sending push messages to users using firebase, the puh is working fine when the app is running or when its in the background , but when i kill the app using multitask tray, its not receiving the push on some devices ,but on some devices its working flawlessly , Seems the app is receiving the push but not showing it. 我正在使用Firebase向用户发送推送消息,当应用程序运行或在后台运行时,puh运行正常,但是当我使用多任务托盘终止应用程序时,它在某些设备上未收到推送,但在某些设备上正常运行,似乎该应用程序正在接收推送,但未显示它。 I searched SO and found similar problems but with no solution to the problem. 我搜索了SO,发现了类似的问题,但没有解决该问题的方法。 As my application is heavily dependent on push messages. 由于我的应用程序严重依赖于推送消息。 Is this any way to implement it? 这有什么实现的方法吗? I am using following code to restart the service but nothing happens. 我正在使用以下代码重新启动服务,但没有任何反应。
@Override
public void onTaskRemoved(Intent rootIntent) {
super.onTaskRemoved(rootIntent);
// Log.d(TAG, "TASK REMOVED");
PendingIntent service = PendingIntent.getService(
getApplicationContext(),
1001,
new Intent(getApplicationContext(), MyFirebaseMessagingService.class),
PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, 1000, service);
}
Some manufactures have restricted app to start automatically. 一些制造商将应用程序限制为自动启动。 So if push comes, our app will not receive that broadcast. 因此,如果推送成功,我们的应用将不会收到该广播。
We have to enable autostart for our app inorder to work push notification in every case. 我们必须为我们的应用启用自动启动功能 ,以便在每种情况下都可以进行推送通知。 There may be some settings named " Autostart " . 可能有一些名为“ 自动启动 ”的设置。 Turn on that for our app. 为我们的应用程序打开它。
Try this way: 尝试这种方式:
{
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
}
"data": {
"message":Hello,
"member_id":"15",
"push_type":2
},
"registration_ids":["er3444@34343sdsadsadsadsad213213"]
}
When app is not available then firebase is trigger default push from notification object, so you need to use notification object by default and data is use for other data. 当应用程序不可用时,firebase会触发来自通知对象的默认推送,因此您需要默认使用通知对象,并且数据将用于其他数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.