PushSharp - android 上的 MismatchSenderID

PushSharp - MismatchSenderID on android

我正在尝试在 Android 设备上实现推送通知。我已经创建了一个 Google 项目并生成了一个服务器 api key there.The server app is asp.net mvc。客户端应用程序是基于 Titanium 的,我们在那里的配置文件中设置发件人 ID。但是我得到了一个 MismatchSenderId 异常。这是我的代码:

public void Notification()
        {
            var objPush = new PushBroker();

            objPush.OnNotificationSent += NotificationSent;
            objPush.OnChannelException += ChannelException;
            objPush.OnServiceException += ServiceException;
            objPush.OnNotificationFailed += NotificationFailed;
            objPush.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
            objPush.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
            objPush.OnChannelCreated += ChannelCreated;
            objPush.OnChannelDestroyed += ChannelDestroyed;

            objPush.RegisterGcmService(new GcmPushChannelSettings(ConfigurationManager.AppSettings["GoogleApiKey"]));

            string registrationId = "APA91bFKeXCvPi7f61N0zIp9wMWPUYk_-hxAlg7jApbskPhHrxH3CKYMQjUPdkqmy-_caNsO1cbKvsSUFi0cN2JcIEjg1-rX30AIW7lR8hjnvjwHI_tSyueXDUBJVuAQme9Lh5lWYd01";

            objPush.QueueNotification(new GcmNotification().ForDeviceRegistrationId(registrationId)
                                  .WithJson("{\"alert\":\"Hello World!\",\"badge\":7,\"sound\":\"sound.caf\"}"));

            objPush.StopAllServices(waitForQueuesToFinish: true);
        }

        static void DeviceSubscriptionChanged(object sender, string oldSubscriptionId, string newSubscriptionId, INotification notification)
        {
            //Currently this event will only ever happen for Android GCM
            Trace.WriteLine("Device Registration Changed:  Old-> " + oldSubscriptionId + "  New-> " + newSubscriptionId + " -> " + notification);
        }

        static void NotificationSent(object sender, INotification notification)
        {
            Trace.WriteLine("Sent: " + sender + " -> " + notification);
        }

        static void NotificationFailed(object sender, INotification notification, Exception notificationFailureException)
        {
            Trace.WriteLine("Failure: " + sender + " -> " + notificationFailureException.Message + " -> " + notification);
        }

        static void ChannelException(object sender, IPushChannel channel, Exception exception)
        {
            Trace.WriteLine("Channel Exception: " + sender + " -> " + exception);
        }

        static void ServiceException(object sender, Exception exception)
        {
            Trace.WriteLine("Channel Exception: " + sender + " -> " + exception);
        }

        static void DeviceSubscriptionExpired(object sender, string expiredDeviceSubscriptionId, DateTime timestamp, INotification notification)
        {
            Trace.WriteLine("Device Subscription Expired: " + sender + " -> " + expiredDeviceSubscriptionId);
        }

        static void ChannelDestroyed(object sender)
        {
            Trace.WriteLine("Channel Destroyed for: " + sender);
        }

        static void ChannelCreated(object sender, IPushChannel pushChannel)
        {
            Trace.WriteLine("Channel Created for: " + sender);
        }

非常感谢任何帮助。

也许尝试使用 Titanium 的几个可用 GCM 模块之一? http://gitt.io/search?q=gcm

或者使用 ArrowDB 推送通知(也使用 GCM): http://docs.appcelerator.com/platform/latest/#!/guide/Configuring_push_services