C# Android推送上的通知失败(注册无效)

C# Android推送上的通知失败(注册无效),c#,android,google-cloud-messaging,push,pushsharp,C#,Android,Google Cloud Messaging,Push,Pushsharp,我已经成功地将推送消息发送到iOS设备,但我遇到了Android的问题。我已获得GCM API密钥和已安装应用程序的设备的注册id 但是,当我尝试发送推送消息时,会触发NotificationFailed事件。我得到的异常类型为PushSharp.Android.GcmMessageTransportResponse,其消息为“无效注册”。我做错了什么 var push = new PushBroker(); push.OnNotificationSent += NotificationSent

我已经成功地将推送消息发送到iOS设备,但我遇到了Android的问题。我已获得GCM API密钥和已安装应用程序的设备的注册id

但是,当我尝试发送推送消息时,会触发
NotificationFailed
事件。我得到的异常类型为
PushSharp.Android.GcmMessageTransportResponse
,其消息为“无效注册”。我做错了什么

var push = new PushBroker();
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;

push.RegisterGcmService(new GcmPushChannelSettings("AIXXXXXXXXXXXXXXXX"));
push.QueueNotification(new GcmNotification()
             .ForDeviceRegistrationId("APAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
.WithJson("{\"alert\":\"Hello World!\",\"badge\":7,\"sound\":\"sound.caf\"}");
push.StopAllServices();

Android的推送通知需要GoogleAPI密钥,可以从GoogleAPI控制台找到,我想您已经有了

您的设备注册id很可能不正确。
请尝试按照以下说明操作:

这绝对是一个API密钥问题。检查从开发者控制台获得的API密钥。它通常以“AIza…”开头

GCM文档中提到了这一确切错误