应用程序被杀死时未收到使用

应用程序被杀死时未收到使用

本文介绍了应用程序被杀死时未收到使用 FCM 的推送通知 android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    public class Notification extends FirebaseMessagingService {

    private static final String TAG = "MyFirebaseNotification";

    @Override
    public void onMessageReceived(final RemoteMessage remoteMessage) {
        Map<String, String> data=null;

        Log.v(TAG,"notification Received");
        Log.v(TAG,remoteMessage.getData().toString());
    }
    }

应用程序被杀死时没有调用方法.即使应用程序被杀死,我如何接收通知,而不是在前台或后台.

Method is not being called when application got killed. How do i receive notifications even if the app is killed,not in foreground or background.

推荐答案

请在您的应用关闭时(重启或刷卡后)检查以下命令

Please check the following command while your app is closed (after a reboot or after swiping)

adb shell dumpsys package MY-PACKAGE | grep stopped

如果您可以阅读 stopped=true,则表示您的设备制造商实施了一种非标准行为,包括在滑动时强制停止"应用程序.

if you can read stopped=true it means that the manufacturer of your device implemented a non standard behavior consisting in "force-stopping" applications when they are swiped.

force-stopping 非常类似于禁用应用程序,直到用户再次打开它.当应用程序处于该状态时,许多 android 行为将不起作用(广播、警报..)

force-stopping is very similar to disabling the app until the user opens it again.while the app is in that state many android behaviors will not work (broadcasts, alarms..)

如果这是您看到的行为的根本原因,您应该联系制造商并要求他们通过删除这种非标准行为来修复设备

If this is the root cause of behavior you are seeing you should contact the manufacturer and request that they fix the device by removing this non-standard behavior

这篇关于应用程序被杀死时未收到使用 FCM 的推送通知 android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:10