如何处理错误让GCM SenderId失败?

时间:2014-04-01 07:34:32

标签: android titanium titanium-mobile google-cloud-messaging

我正在尝试将GCM与Titanium Studio一起使用,我希望能够在我的Android应用中实现推送通知: 我正在使用下面的代码:

var CloudPush = require('ti.cloudpush');
var deviceToken = null;


CloudPush.retrieveDeviceToken({
    success: deviceTokenSuccess,
    error: deviceTokenError
});

function deviceTokenSuccess(e) {
    CloudPush.enabled = true;
    deviceToken = e.deviceToken;
}

function deviceTokenError(e) {
    alert('Failed to register for push notifications! ' + e.error);
}

CloudPush.addEventListener('callback', function (evt) {
    alert(evt.payload);
});

CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
    Ti.API.info('Tray Click Launched App (app was not running)');
});


CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
    Ti.API.info('Tray Click Focused App (app was already running)');
});

当我运行代码时,我收到错误: 无法注册推送通知!接收GCM SenderId失败,导致GCM SenderId失败。最大重试时间达到。

我可以做些什么来解决这个错误?

1 个答案:

答案 0 :(得分:-1)

您的代码中有很多错误,我认为您没有设置GCM发件人ID。您必须遵循本教程,我认为您会很高兴

http://www.tidev.io/2013/12/20/using-gcm-for-android-push-notifications-with-acs/

由于