arleyandrada / PushClient

FREE and Open Source - Titanium PushClient Module
Other
44 stars 17 forks source link

Android TiExceptionHandler #118

Closed ruscles closed 8 years ago

ruscles commented 8 years ago

Hi,

I am able to register and receive push notifications on iOS, but I get the following crash on Android:

[INFO]  registerPush...
[WARN]  W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
[WARN]  W/System.err:   at br.com.arlsoft.pushclient.PushClientModule.registerPush(PushClientModule.java:180)
[WARN]  W/System.err:   at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
[WARN]  W/System.err:   at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:177)
[WARN]  W/System.err:   at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:299)
[WARN]  W/System.err:   at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:203)
[WARN]  W/System.err:   at android.os.Handler.dispatchMessage(Handler.java:98)
[WARN]  W/System.err:   at android.os.Looper.loop(Looper.java:145)
[WARN]  W/System.err:   at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
[ERROR] TiExceptionHandler: (main) [859,859] ----- Titanium Javascript Runtime Error -----
[ERROR] TiExceptionHandler: (main) [1,860] - In alloy/controllers/index.js:1,69
[ERROR] TiExceptionHandler: (main) [0,860] - Message: Uncaught Error: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
[ERROR] TiExceptionHandler: (main) [0,860] - Source: dEventListener(h.EVENT_CALLBACK,w),Ti.API.info("registerPush..."),h.registerPu
[ERROR] V8Exception: Exception occurred at alloy/controllers/index.js:1: Uncaught Error: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference

I am using SDK 5.1.1 installing on Android 5.0.1 with Google Play Services 8.4.89. Any thoughts on how to troubleshoot this? Thanks!

arleyandrada commented 8 years ago

Hi Ruscles,

This error occurres when you don't set the GCMSenderId as a parameter to the registerPush method.

var registerOptions = {
    GCMSenderId : "Set your GCM Sender Id here as a string value",
    APNTypes : [ PushClient.NOTIFICATION_TYPE_BADGE, PushClient.NOTIFICATION_TYPE_ALERT, PushClient.NOTIFICATION_TYPE_SOUND ]
};
PushClient.registerPush(registerOptions);

Regards,

Arley