应用程序被杀死时未收到使用 FCM 的推送通知 android

Push notifications using FCM not received when app is killed android(应用程序被杀死时未收到使用 FCM 的推送通知 android)
本文介绍了应用程序被杀死时未收到使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)