【发布时间】:2014-05-11 20:25:19
【问题描述】:
我正在尝试将 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 失败。达到最大重试时间。
我可以做些什么来解决这个错误?
【问题讨论】:
标签: android titanium titanium-mobile google-cloud-messaging