Quantcast
Viewing all articles
Browse latest Browse all 8068

Unable to receive Push notifications to Notifications Tray on Android

Hi,

I have been trying to get Push notifications working for an android application. When the app is focussed, the push is received just fine. However, when the application is in the background, i see an error in the log.

My code is -

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));
    });

and the error im receiving is -

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

Any thoughts on how i could work this out is highly appreciated.

Im using Titanium SDK - 3.2.3 GA.


Viewing all articles
Browse latest Browse all 8068

Trending Articles