无法在Appcelerator Android上接收到通知托盘的推送通知

时间:2014-07-21 04:51:45

标签: push-notification google-cloud-messaging android-notifications appcelerator-mobile

我一直在努力让推送通知适用于Android应用程序。当应用程序聚焦时,推送收到很好。但是,当应用程序在后台时,我在日志中看到错误。

我的代码是 -

var CloudPush = require('ti.cloudpush');
CloudPush.retrieveDeviceToken({
    success: function deviceTokenSuccess(e) {
        console.log('Device Token: ' + e.deviceToken);
        token = e.deviceToken;
        that.token=token;
    },
    error: function deviceTokenError(e) {
        console.log('Token Error: ' + e.error);
    }
});

CloudPush.debug                 = true;
CloudPush.focusAppOnPush        = false;
CloudPush.enabled               = true;
// CloudPush.showAppOnTrayClick = false;
CloudPush.showTrayNotification  = true;
// CloudPush.singleCallback     =  true;

CloudPush.addEventListener('callback', function(evt){
    alert('A push notification was received!');
    console.log('A push notification was received!' + JSON.stringify(evt));
});

CloudPush.addEventListener('trayClickLaunchedApp', function(evt){
    alert('A push notification was received - onLaunched');
    console.log('A push notification was received!' + JSON.stringify(evt));
});

CloudPush.addEventListener('trayClickFocusedApp', function(evt){
    alert('A push notification was received - onFocused');
    console.log('A push notification was received!' + JSON.stringify(evt));
});

我收到的错误是 -

07-18 14:19:44.853: E/TiApplication(25319): (main) [9,46101] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver ti.cloudpush.GCMReceiver: java.lang.NullPointerException; Titanium 3.2.3,2014/04/22 10:17,b958a70 
07-18 14:19:44.853: E/TiApplication(25319): java.lang.RuntimeException: Unable to start receiver ti.cloudpush.GCMReceiver: java.lang.NullPointerException

对我如何解决这个问题的任何想法都非常感谢。

我正在使用Titanium SDK - 3.2.3 GA。

0 个答案:

没有答案