无法显示收到的Firebase快速入门示例消息通知 [英] Unable to dispay the received firebase quickstart sample messaging notification

查看:1282
本文介绍了无法显示收到的Firebase快速入门示例消息通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从以下 https://试用版的Firebase云消息传递快速入门示例代码(Android) firebase.google.com/docs/samples



我设法运行示例代码,但是当我尝试从Firebase控制台发送通知时,尽管我可以看到我在logcat中发送的通知内容,但没有显示在我的Android Studio模拟器中。 logcat中有很少的错误。

我正在使用Android Studio 2.1.1
Windows 64位
模拟器Nexus_5x
Android API 23



正如我可以看到通知在logcat,有效载荷为你好3

  05-30 15:13:25.746 2729-7428 / com.google.firebase.quickstart.fcm D / MyFirebaseMsgService:发件人:621412269084 
05-30 15:13:25.746 2729-7428 / com.google.firebase。 quickstart.fcm D / MyFirebaseMsgService:通知消息正文:hello 3

/ p>

  05-30 15:09:14.229 2729-2729 / com.google.firebase.quickstart.fcm D / MainActivity:InstanceID令牌:
d58dJBNq_-E:在发现APA91bHd8ZnNmVfKmMIEwnYgcx-T77E8UwU_jrrZkC4WWoZ6uZ-2lL6Dg4zZEEMvtUs2V86VjnNogOcAZKa1LF7ICvxNrEuWADgsibXt_6XoKDVmAvmsAFrzmJM4l8_Q-DcbjhN55kEx

很少的错误logcat

  05-30 15:12:06.967 2234-6271 / com.google.android.gms I / EventLogChimeraService:Aggregate from 14 64619326768(log),1464619326768(data)
05-30 15:12:07.029 2234-6275 / com.google.android.gms D / DropBoxEntryAddedChimeraService:用户没有选择使用&诊断。
05-30 15:12:07.070 2234-6276 / com.google.android.gms D / DropBoxEntryAddedChimeraService:用户没有选择使用&诊断。
05-30 15:13:25.724 1866-2597 / com.google.android.gms.persistent D / GCM:错误白名单应用程序在
中唤醒java.lang.reflect.InvocationTargetException $ b $ (SourceFile:49473)
at ott.c(SourceFile:1366)
at otn.b(源文件)
at ott.a(SourceFile:49473) (SourceFile:998)
at ahgf.run(SourceFile:1070)
at java.lang.Thread.run(Thre ad.java:818)
导致:java.lang.SecurityException:调用应用程序u0a7不在白名单上
在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)
05-30 15:13:25.735 2729-7429 / com.google.firebase.quickstart .fcm I / FA:找不到标签管理器,因此不会使用
05-30 15:13:25.746 2729-7428 / com.google.firebase.quickstart.fcm D / MyFirebaseMsgService:From:621412269084
05-30 15:13:25.746 2729-7428 / com.google.firebase.quickstart.fcm D / MyFirebaseMsgService:通知消息正文:hello 3
05-30 15:13:25.928 1200-1940 / ? D / WVCdm:实例化CDM。
05-30 15:13:25.929 1200-1602 /? I / WVCdm:CdmEngine :: OpenSession
05-30 15:13:25.929 1200-1602 /? I / WVCdm:Level3库Sep 28 2015 13:08:28
05-30 15:13:25.930 1200-1602 /? W / WVCdm:无法读取/data/mediadrm/IDM1013/ay64.dat2:没有这样的文件或目录
05-30 15:13:25.930 1200-1602 /? W / WVCdm:无法加载liboemcrypto.so。回落到L3。 dlopen失败:库liboemcrypto.so未找到
05-30 15:13:25.932 1535-2145 / system_process I / AccountManagerService:getTypesVisibleToCaller:isPermitted?真
05-30 15:13:25.947 1200-1602 /? I / WVCdm:CdmEngine :: QueryKeyControlInfo
05-30 15:13:25.949 1200-1200 /? W / WVCdm:BufferReader :: Read< T> :解析失败:字节不够(4)
05-30 15:13:25.949 1200-1200 /? W / WVCdm:CdmEngine :: ExtractWidevinePssh:无法读取原子大小。
05-30 15:13:25.949 1200-1200 /? I / WVCdm:CdmEngine :: GenerateKeyRequest
05-30 15:13:25.950 1200-1200 /? D / WVCdm:PrepareKeyRequest:nonce = 1125203836
05-30 15:13:26.041 1200-1991 /? I / WVCdm:CdmEngine :: CloseSession
05-30 15:13:26.061 1866-7431 / com.google.android.gms.persistent I / PhenotypeFlagCommitter:实验Configs成功检索com.google.android.gms。 playlog.uploader
05-30 15:13:26.062 1866-7431 / com.google.android.gms.persistent I / GoogleURLConnFactory:使用平台SSLCertificateSocketFactory
05-30 15:13:26.086 1535-2728 / system_process I / AccountManagerService:getTypesVisibleToCaller:isPermitted? true

[05-30 15:13:26.447 3544:3557 D /]
HostConnection :: get()建立新的主机连接0xae428680,tid 3557
05-30 15 :13:26.505 1535-1929 / system_process I / AccountManagerService:getTypesVisibleToCaller:isPermitted? true
05-30 15:13:26.635 1535-1898 / system_process I / AccountManagerService:getTypesVisibleToCaller:isPermitted? true
05-30 15:13:26.637 1535-1546 / system_process I / AccountManagerService:getTypesVisibleToCaller:isPermitted? true
05-30 15:13:26.637 1866-7431 / com.google.android.gms.persistent W / Uploader:不再存在,所以没有认证令牌。
05-30 15:13:26.777 1535-1546 / system_process I / AccountManagerService:getTypesVisibleToCaller:isPermitted? true
05-30 15:13:26.977 1866-7432 / com.google.android.gms.persistent W / GLSUser:[AppCertManager]请求键时发生IOException:
java.io.IOException:设备无效关键响应。 exx.a(SourceFile:267)
(Ext.a(SourceFile:2235))
Exw.a(SourceFile:46)
exx.a(SourceFile: 55)
at exp.a(SourceFile:113)
at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.a(SourceFile:1054)
at ovi .run(SourceFile:179)
05-30 15:13:32.163 2234-7537 / com.google.android.gms D / DropBoxEntryAddedChimeraService:用户没有选择使用&诊断。


解决方案

使用Firebase Cloud Messaging display-messages自动显示只有当应用程序不在前台(如它关闭或在后台)。

当应用程序在前台 onMessageReceived()方法将被调用,以允许开发人员在应用程序内部显示消息或自己生成通知。



这与数据消息(使用

{data:{...}} 有效载荷通过服务器端api发送的消息不同)总是调用 onMessageReceived()方法。


I'm trying out the Firebase Cloud Messaging Quickstart sample code (Android) from the following https://firebase.google.com/docs/samples

I managed to run the sample code, but when i try to send the notification from the Firebase console, despite i can see the notification content i sent in the logcat, but it didn't display in my Android Studio Emulator. There are few errors in the logcat.

I'm using Android Studio 2.1.1 Windows 64-bit Emulator Nexus_5x Android API 23

As i can see the notification in logcat, with payload as "hello 3"

05-30 15:13:25.746 2729-7428/com.google.firebase.quickstart.fcm D/MyFirebaseMsgService: From: 621412269084
05-30 15:13:25.746 2729-7428/com.google.firebase.quickstart.fcm D/MyFirebaseMsgService: Notification Message Body: hello 3

the token id was taken from below

05-30 15:09:14.229 2729-2729/com.google.firebase.quickstart.fcm D/MainActivity: InstanceID token:
d58dJBNq_-E:APA91bHd8ZnNmVfKmMIEwnYgcx-T77E8UwU_jrrZkC4WWoZ6uZ-2lL6Dg4zZEEMvtUs2V86VjnNogOcAZKa1LF7ICvxNrEuWADgsibXt_6XoKDVmAvmsAFrzmJM4l8_Q-DcbjhN55kEx

Few errors found in the logcat

05-30 15:12:06.967 2234-6271/com.google.android.gms I/EventLogChimeraService: Aggregate from 1464619326768 (log), 1464619326768 (data)
05-30 15:12:07.029 2234-6275/com.google.android.gms D/DropBoxEntryAddedChimeraService: User is not opted-in to Usage & Diagnostics.
05-30 15:12:07.070 2234-6276/com.google.android.gms D/DropBoxEntryAddedChimeraService: User is not opted-in to Usage & Diagnostics.
05-30 15:13:25.724 1866-2597/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 u0a7 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) 
05-30 15:13:25.735 2729-7429/com.google.firebase.quickstart.fcm I/FA: Tag Manager is not found and thus will not be used
05-30 15:13:25.746 2729-7428/com.google.firebase.quickstart.fcm D/MyFirebaseMsgService: From: 621412269084
05-30 15:13:25.746 2729-7428/com.google.firebase.quickstart.fcm D/MyFirebaseMsgService: Notification Message Body: hello 3
05-30 15:13:25.928 1200-1940/? D/WVCdm: Instantiating CDM.
05-30 15:13:25.929 1200-1602/? I/WVCdm: CdmEngine::OpenSession
05-30 15:13:25.929 1200-1602/? I/WVCdm: Level3 Library Sep 28 2015 13:08:28
05-30 15:13:25.930 1200-1602/? W/WVCdm: Could not read /data/mediadrm/IDM1013/ay64.dat2: No such file or directory
05-30 15:13:25.930 1200-1602/? W/WVCdm: Could not load liboemcrypto.so. Falling back to L3.  dlopen failed: library "liboemcrypto.so" not found
05-30 15:13:25.932 1535-2145/system_process I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
05-30 15:13:25.947 1200-1602/? I/WVCdm: CdmEngine::QueryKeyControlInfo
05-30 15:13:25.949 1200-1200/? W/WVCdm: BufferReader::Read<T> : Failure during parse: Not enough bytes (4)
05-30 15:13:25.949 1200-1200/? W/WVCdm: CdmEngine::ExtractWidevinePssh: Unable to read atom size.
05-30 15:13:25.949 1200-1200/? I/WVCdm: CdmEngine::GenerateKeyRequest
05-30 15:13:25.950 1200-1200/? D/WVCdm: PrepareKeyRequest: nonce=1125203836
05-30 15:13:26.041 1200-1991/? I/WVCdm: CdmEngine::CloseSession
05-30 15:13:26.061 1866-7431/com.google.android.gms.persistent I/PhenotypeFlagCommitter: Experiment Configs successfully retrieved for com.google.android.gms.playlog.uploader
05-30 15:13:26.062 1866-7431/com.google.android.gms.persistent I/GoogleURLConnFactory: Using platform SSLCertificateSocketFactory
05-30 15:13:26.086 1535-2728/system_process I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true

                                                                     [ 05-30 15:13:26.447  3544: 3557 D/         ]
                                                                     HostConnection::get() New Host Connection established 0xae428680, tid 3557
05-30 15:13:26.505 1535-1929/system_process I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
05-30 15:13:26.635 1535-1898/system_process I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
05-30 15:13:26.637 1535-1546/system_process I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
05-30 15:13:26.637 1866-7431/com.google.android.gms.persistent W/Uploader:  no longer exists, so no auth token.
05-30 15:13:26.777 1535-1546/system_process I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
05-30 15:13:26.977 1866-7432/com.google.android.gms.persistent W/GLSUser: [AppCertManager] IOException while requesting key: 
                                                                          java.io.IOException: Invalid device key response.
                                                                              at exx.a(SourceFile:267)
                                                                              at exx.a(SourceFile:2235)
                                                                              at exw.a(SourceFile:46)
                                                                              at exq.a(SourceFile:55)
                                                                              at exp.a(SourceFile:113)
                                                                              at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.a(SourceFile:1054)
                                                                              at ovi.run(SourceFile:179)
05-30 15:13:32.163 2234-7537/com.google.android.gms D/DropBoxEntryAddedChimeraService: User is not opted-in to Usage & Diagnostics.

解决方案

With Firebase Cloud Messaging display-messages are automatically displayed only when the application is NOT in foreground (like it's closed or in background).

When the application is in foreground the onMessageReceived() method will be called instead, to allow the developer to display the message inside the application or to generate a notification himself.

This is different from data-messages (messages sent via the server-side api with the
{"data": {...}} payload) which always invoke the onMessageReceived() method.

这篇关于无法显示收到的Firebase快速入门示例消息通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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