简体   繁体   English

当从联想等某些设备上的多任务托盘中杀死应用程序时,Android应用程序未收到Firebase推送通知

[英]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
  },
 "re‌​gistration_ids":["er‌​3444@34343sdsadsadsa‌​dsad213213"]
}

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.

相关问题 当应用程序从多任务托盘停止时,Android 应用程序未收到 Firebase 通知 - Android app not receiving Firebase Notification when app is stopped from multi-task tray firebase 推送通知在某些设备 (Android) 中被杀死的应用程序不起作用 state - firebase push notification is not working on app killed state in some devices (Android) Android上的小米和联想设备上的应用程序被杀后,未收到GCM通知 - Not receiving GCM notifications once app is killed on Xiaomi and Lenovo devices in Android 当应用程序被杀死时,FireBase仅在以下Android 6.0设备中不接收推送通知 - FireBase not receiving push notification only in below android 6.0 device when Application killed 即使应用程序被杀死,如何向Android设备发送推送通知? - How to send push notification to android devices even when app is killed? 应用程序被终止时,设备未收到推送通知 - push notification not received to devices when app is killed 应用程序被杀时,Android Firebase Push通知无效 - Android Firebase Push notification not working when application is killed Android-多任务? - Android - Multi-Task? 在Android上杀死应用时收到系统托盘通知 - Receive system tray notification when app killed on Android 在Android设置应用程序图标时的应用程序图标上的徽章编号或在接收Facebook应用程序等通知时被杀死 - On Android setting badge number on app icon when app is in background or killed when receiving notification like facebook app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM