简体   繁体   English

应用程序在后台(模拟器)时,Firebase推送通知未显示

[英]Firebase push notifications not showing up while app is in background (Emulator)

I send firebase push notification to a singe android device from the firebase console. 我将Firebase推送通知从Firebase控制台发送到一个Android设备。 This works well while the app is running in the foreground. 当应用程序在前台运行时,此方法效果很好。 I receive the event and onMessageReceived() is called. 我收到事件并调用onMessageReceived()。 When the app is in the background I'm expecting to see an notification entry to show up in the system notification tray of the emulator. 当应用程序在后台运行时,我希望看到一个通知条目显示在模拟器的系统通知托盘中。 Instead I'm getting the error below and no notification is popping up on the device. 相反,我收到以下错误,并且设备上没有弹出通知。 My messages are very simple just the message text and the FCM token. 我的消息非常简单,只是消息文本和FCM令牌。

Update: It seems to be a emulator issue because on a real device it is working. 更新:这似乎是模拟器问题,因为它在实际设备上正在运行。

com.google.android.gms.persistent D/GCM: Error whitelisting app for waking in doze java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at ott.a(SourceFile:49473) at ott.c(SourceFile:1366) at otn.b(SourceFile:638) at ahge.a(SourceFile:998) at ahgf.run(SourceFile:1070) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.SecurityException: Calling app is not on whitelist at android.os.Parcel.readException(Parcel.java:1599) at android.os.Parcel.readException(Parcel.java:1552) at android.app.usage.IUsageStatsManager$Stub$Proxy.whitelistAppTemporarily(IUsageStatsManager.java:293) at android.app.usage.UsageStatsManager.whitelistAppTemporarily(UsageStatsManager.java:266) at java.lang.reflect.Method.invoke(Native Method) at ott.a(SourceFile:49473) at ott.c(SourceFile:1366) at otn.b(SourceFile:638) at ahge.a(SourceFile:998) at ahgf.run(SourceFile:1070) at java.lang.Thread.run(Thread.java:818) com.google.android.gms.persistent D / GCM:在将Dot.a处java.lang.reflect.Method.invoke(本机方法)处的java.lang.reflect.InvocationTargetException唤醒时将应用列入白名单的错误(源文件:49473)在ott.c(SourceFile:1366)在otn.b(SourceFile:638)在ahge.a(SourceFile:998)在ahgf.run(SourceFile:1070)在java.lang.Thread.run(Thread.java:818) )由以下原因引起:java.lang.SecurityException:android.os.Parcel.readException(Parcel.java:1552)上的android.os.Parcel.readException(Parcel.java:1599)上的调用应用不在白名单上.ottage的.usage.IUsageStatsManager $ Stub $ Proxy.whitelistAppTemporarily(IUsageStatsManager.java:293)在android.app.usage.UsageStatsManager.whitelistAppTemporarily(UsageStatsManager.java:266)在java.lang.reflect.Method.invoke(本机方法) .a(SourceFile:49473)位于ott.c(SourceFile:1366)在otn.b(SourceFile:638)在ahge.a(SourceFile:998)在ahgf.run(SourceFile:1070)在java.lang.Thread。运行(Thread.java:818)

Should use GCM high-priority messages to wake the app and access the network. 应该使用GCM高优先级消息唤醒应用程序并访问网络。 Example of High priority GCM message:- 高优先级GCM消息示例:-

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "priority" : "high",
   "notification" : {
    "body" : "This week’s edition is now available.",
    "title" : "NewsMagazine.com",
    "icon" : "new",
  },
  "data" : {
    "volume" : "3.21.15",
    "contents" : "http://www.news-magazine.com/world-week/21659772"
  }
}

See the "priority" key has value "high", this will awake the device and gcm message will be delivered instantly and it wont crash. 看到“优先级”键的值为“高”,这将唤醒设备,并且gcm消息将立即发送,并且不会崩溃。

Check this out for more information https://developer.android.com/training/monitoring-device-state/doze-standby.html#whitelisting-cases 查看此以获取更多信息https://developer.android.com/training/monitoring-device-state/doze-standby.html#whitelisting-cases

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当应用程序在带有 firebase 的后台时,使推送通知显示为弹出 - Make push notifications appear as pop up when app is on background with firebase Firebase 推送通知在后台应用程序时显示错误图标 - Firebase push notifications show wrong icon when app in background Cordova中的后台Firebase推送通知 - Background Firebase Push Notifications in Cordova 使用Firebase推送通知 - Push up notifications using firebase 带有来自服务器(php)的图像的 Android Firebase 推送通知未在通知中显示图像,而应用程序在后台 - Android Firebase Push Notification with image from server(php) not showing image in notification while app in background 在后台运行应用程序时推送通知行为(解析/ Unity / Android) - Push notifications behaviour while app running in background (Parse/Unity/Android) 使用 Firebase 处理后台推送通知,支持 Doze - Handle background push notifications with Firebase, supporting Doze Firebase 推送通知与 cordova 前景和背景 n - Firebase push notifications with cordova foreground and background n Android通知未显示在应用程序中 - Android notifications not showing up in app 应用程序图标未显示在模拟器上 - App icon not showing up on emulator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM