【问题标题】:Xamarin GCM push notification not workingXamarin GCM 推送通知不起作用
【发布时间】:2016-12-29 14:42:26
【问题描述】:

我正在一步一步地进行,并且完全复制了以下教程中提供的代码:

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/notifications/android/remote_notifications_in_android/

顺便说一句,我正在用我的 API KEY 替换,我正在使用 USB 调试、我的 moto g、运行 cyanogenmod 和 mashmallow 进行测试。

我无法收到推送通知,也没有收到任何错误。这有什么线索吗?

更新 这是日志猫。我读到有时这个错误是由于缺少 google-services.json,但 xamarin 似乎不需要它。

08-23 14:19:50.207 I/GMPM    ( 9213): App measurement is starting up, version: 8487
08-23 14:19:50.207 I/GMPM    ( 9213): To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
08-23 14:19:50.216 E/GMPM    ( 9213): GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
08-23 14:19:50.216 E/GMPM    ( 9213): Scheduler not set. Not logging error/warn.
08-23 14:19:50.231 E/GMPM    ( 9213): Uploading is not possible. App measurement disabled
08-23 14:20:26.066 I/GMPM    ( 9213): Tag Manager is not found and thus will not be used
08-23 14:21:35.288 I/GMPM    ( 9547): App measurement is starting up, version: 8487
08-23 14:21:35.288 I/GMPM    ( 9547): To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
08-23 14:21:35.295 E/GMPM    ( 9547): GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
08-23 14:21:35.295 E/GMPM    ( 9547): Scheduler not set. Not logging error/warn.
08-23 14:21:35.312 E/GMPM    ( 9547): Uploading is not possible. App measurement disabled

Full logcat here.

【问题讨论】:

  • adb logcat 中应该有很多日志可以搜索。你在哪一步失败了?它本身就是一个相当大的指南。
  • 我认为它没有失败。我完成了整个教程,我只是在 logcat 中没有收到任何错误的通知
  • 如果是调试模式,那么在运行应用程序时,您的 OnMessage 函数是否命中?你可以看看这个 - stackoverflow.com/a/29126946/1155650
  • 感谢 @JonDouglas 和 Rohit 的 cmets。我更新了问题

标签: xamarin push-notification google-cloud-messaging xamarin.android


【解决方案1】:

我遇到了同样的问题。当我最初运行文件 MessageSender.exe 时,消息已成功发送以添加到我的主题,但 Xamarin 应用程序没有收到任何推送通知。我的问题出在 WiFi 路由器的防火墙设置中。当我切换到手机的 4G 数据网络时,我在设备上收到了消息。它对我有用,但我不确定这是否是你的问题。如果这没有帮助,您会提供更多信息(日志记录)吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-08
    • 2019-09-17
    • 2021-11-14
    • 2013-02-02
    相关资源
    最近更新 更多