Xamarin GCM推送通知无效

时间:2016-08-22 22:45:18

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

我正在逐步完成,并完全复制以下教程中提供的代码:

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

顺便说一句,我正在用我的API KEY替换,我正在测试使用usb调试,我的机器人运行cyanogenmod,使用mashmallow。

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

更新 这是logcat。我读过有时候这个错误是由于缺少了google-services.json,但是xamarin并不需要它。

let key = self.keys[0]
let mac = key.lockMACAddress!
guard let specificperipheral = self.locks[mac] else {
    print("No peripheral found")
    return
}

// Perform an unlock operation. You may also attach an onComplete handler.
lockDevice?.performUnlock(specificperipheral, key: key).onCompletedAndDisconnected({ (data) -> () in
    print("Finished")
}).onFail({ (error) -> () in
    print("Error")
})

Full logcat here.

1 个答案:

答案 0 :(得分:1)

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

相关问题