应用关闭时未显示通知 [英] Notification not showing when the app is closed

查看:158
本文介绍了应用关闭时未显示通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关闭应用程序时,仅使用数据有效负载不会收到任何通知,并且不会触发onMessageReceive方法.

Only use of data payload not receive any notification when app is closed, and also onMessageReceive method is not triggered.

在下面的图像中显示数据有效载荷 单击此处查看参数

In bellow image show data payload click here to view parameter

且响应为单击此处查看响应

响应成功1,但在Redmi电话中未收到任何通知.

In response success 1 but not receive any notification in redmi phone.

推荐答案

为所有设备支持Fire-base推送通知就像一个迷宫. 推送通知有3种情况

Supporting Fire-base push notification for all device is like a maze. There are 3 scenario for push notification

  1. 前景(触发FirebaseMessagingServiceonMessageReceived方法)
  2. 背景(无法触发FirebaseMessagingService,但firebase服务将其消息推送到设备的通知托盘)
  3. 应用程序杀死(无法触发FirebaseMessagingService firebase服务推送将其消息推送到设备的通知托盘)
  1. Foreground (fire FirebaseMessagingService's onMessageReceived method)
  2. Background (can't fire FirebaseMessagingService but firebase service push their message into device's Notification Tray)
  3. App kill (can't fire FirebaseMessagingService firebase service push push their message into device's Notification Tray)

注意:当您从后台堆栈中滑出时,某些中文设备(如小米,华硕,华为等)会强制停止您的应用程序,从而导致该服务被终止.因此,firebase服务无法运行,并且无法将其通知推送到通知"托盘.

NOTE: Some chinese device like Xiaomi, Asus, Huawei etc. are force stop your app when you swipe out from your background stack, so that the service is kill. For that reason firebase service is not run and can't push their notification into Notification tray.

在小米中-安全->权限->自动启动,然后选中您的应用.启用此功能意味着应用程序的任何服务始终在后台运行.然后,您每次都会从应用程序中收到各种通知.

In Xiaomi - security-->permissions-->autostart then check mark your app. Enable this means app's any service always run in background. Then you get all kinds of notification from your app every time.

如果您想了解更多有关此的信息,请确认 并且如果您想从应用程序转到特定设备的安全页面,请选中此.

If you want to learn more about that, Check that and if you want to go particular device's security page from your app then check this.

这篇关于应用关闭时未显示通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆