Just upgraded my app to Appcelerator Platform and SDK 4.0.0. If I do a fresh install on my android phone, I get the following error. It behaves as if a push notification is coming in, but there is actually none. Any idea?
[ERROR] : APSCloudPush: Payload is null!
[ERROR] : TiApplication: (main) [4889,4889] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference; Titanium 4.0.0,2015/05/18 15:42,9239ff9
[ERROR] : TiApplication: java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
[ERROR] : TiApplication: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2726)
[ERROR] : TiApplication: at android.app.ActivityThread.access$1700(ActivityThread.java:144)
[ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:155)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5696)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:372)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
[ERROR] : TiApplication:
[ERROR] : TiApplication: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
[ERROR] : TiApplication: at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
[ERROR] : TiApplication: at org.json.JSONTokener.nextValue(JSONTokener.java:94)
[ERROR] : TiApplication: at org.json.JSONObject.<init>(JSONObject.java:156)
[ERROR] : TiApplication: at org.json.JSONObject.<init>(JSONObject.java:173)
[ERROR] : TiApplication: at com.appcelerator.aps.APSCloudPush.showTrayNotification(APSCloudPush.java:347)
[ERROR] : TiApplication: at com.appcelerator.aps.APSCloudPush.receivePayload(APSCloudPush.java:253)
[ERROR] : TiApplication: at com.appcelerator.aps.GCMReceiver.onReceive(GCMReceiver.java:30)
[ERROR] : TiApplication: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2712)
[ERROR] : TiApplication: ... 9 more
Here is the js code:
var CloudPush = require('ti.cloudpush');
var rc = CloudPush.isGooglePlayServicesAvailable();
if(rc == CloudPush.SUCCESS){
var flagBgPush = function(){
bgPush = true;
};
CloudPush.retrieveDeviceToken({
success: deviceTokenSuccess,
error: function(){}
});
CloudPush.addEventListener('trayClickLaunchedApp', flagBgPush);
CloudPush.addEventListener('trayClickFocusedApp', flagBgPush);
CloudPush.addEventListener('callback', pushBackgroundCheck);
}
Are you using a php script to send notifications ??
if so i suggest you to use this script works fine for me :