Pushwoosh / pushwoosh-appcelerator-titanium

Other
33 stars 16 forks source link

[Android] onPushOpened don't fired when app is close #44

Closed gioggio79 closed 6 years ago

gioggio79 commented 7 years ago

As title, we have a issue.

When we close the appand send a notification via https://go.pushwoosh.com, the notification is showed right on Android, but when we click on it, the application is opend, but we have this error: [ERROR] : PushnotificationsModule: (main) [52,23961] Failed to convert push message data [ERROR] : PushnotificationsModule: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator org.json.JSONObject.keys()' on a null object reference [ERROR] : PushnotificationsModule: at com.pushwoosh.internal.utils.JsonUtils.jsonToMap(Unknown Source) [ERROR] : PushnotificationsModule: at com.pushwoosh.module.PushnotificationsModule.convertMessageData(PushnotificationsModule.java:426) [ERROR] : PushnotificationsModule: at com.pushwoosh.module.PushnotificationsModule.access$200(PushnotificationsModule.java:43) [ERROR] : PushnotificationsModule: at com.pushwoosh.module.PushnotificationsModule$2.run(PushnotificationsModule.java:347) [ERROR] : PushnotificationsModule: at android.app.Activity.runOnUiThread(Activity.java:5524) [ERROR] : PushnotificationsModule: at com.pushwoosh.module.PushnotificationsModule.onNotificationOpened(PushnotificationsModule.java:335) [ERROR] : PushnotificationsModule: at com.pushwoosh.module.NotificationReceiver.onReceive(NotificationReceiver.java:80) [ERROR] : PushnotificationsModule: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2725) [ERROR] : PushnotificationsModule: at android.app.ActivityThread.-wrap14(ActivityThread.java) [ERROR] : PushnotificationsModule: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421) [ERROR] : PushnotificationsModule: at android.os.Handler.dispatchMessage(Handler.java:102) [ERROR] : PushnotificationsModule: at android.os.Looper.loop(Looper.java:148) [ERROR] : PushnotificationsModule: at android.app.ActivityThread.main(ActivityThread.java:5417) [ERROR] : PushnotificationsModule: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : PushnotificationsModule: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) [ERROR] : PushnotificationsModule: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

and no onPushOpened fired.

If the app is open or only in background but not closed, the notification works right. onPushOpened is correctly fired.

This issue is on Android 4.4/6/7 Titanium 6.0.2, 6.1.0

(sorry for my English, I hope everything is clear) Regards

DimanAM commented 7 years ago

Should be fixed in 3.3.1

gioggio79 commented 7 years ago

Thanks for really fast fix. Now we don't have any [ERROR], however the notification works only on open/background application (as before).

If I close the app (by task manager or close with titanium activity.finish()) the event onPushOpened doesn't work.

My code in index.js var pushwoosh = require('com.pushwoosh.module'); pushwoosh.onPushOpened(function(e) { Ti.API.info("onPushOpened", JSON.stringify(e)); }); pushwoosh.initialize({ "application" : "xxxxxxx", \\my custom data "gcm_project" : "xxxxxxxx" \\my custom data }); pushwoosh.registerForPushNotifications(function(e) { // successful push registration here var pushToken = e.registrationId; showHome(); //my function }, function(e) { // push registration error here var errorMessage = e.error; showHome(); //my function });

I forgot something? (in tiapp.xml o someone else?)

DimanAM commented 7 years ago

This is strange. I do not see anything wrong in your code and I cannot reproduce this problem. I have added more detailed logging in 3.3.2 version. If the issue persists please submit device logs.

gioggio79 commented 7 years ago

Ok, we got it. The problem is only with Titanium < 6.1.0 (6.0.2, 6.0.3 etc). But with the 6.1 version the event onPushOpened is correctly fired.

This is a Log from 6.0.2 exports

[INFO] : Pushwoosh: [com.pushwoosh.GCMListenerService] Received message: Bundle[{google.sent_time=1498471212896, pw_msg=1, p=B, pri=, vib=0, type=prodotto, title=test app, google.message_id=0:1498471212904947%%d2eff081f9fd7ecd, content=1431087}] from: 522943145423 [INFO] : Pushwoosh: [AbsNotificationFactory] nofify: Bundle[{google.sent_time=1498471212896, onStart=true, pw_msg=1, p=B, pri=, vib=0, type=prodotto, title=test app, google.message_id=0:1498471212904947%%d2eff081f9fd7ecd, content=1431087, foreground=false}] [INFO] : Pushwoosh: [RequestManager] [INFO] : Pushwoosh: x [INFO] : Pushwoosh: | Pushwoosh request: [INFO] : Pushwoosh: | Url: https://xxxxxxxx.api.pushwoosh.com/json/1.3/messageDeliveryEvent [INFO] : Pushwoosh: | Payload: {"request":{"v":"4.12.2","device_type":3,"application":"B6E59-AF63F","hwid":"xxxxxxxxxx","hash":"B","userId":"xxxxxxxxxxxxxx"}} [INFO] : Pushwoosh: | Response: {"status_code":200,"status_message":"OK","response":null} [INFO] : Pushwoosh: x APP CLOSE OPEN APP -> [WARN] : Pushwoosh: [b] No android.permission.BROADCAST_STICKY. Reverting to simple broadcast [INFO] : Pushwoosh: [RequestManager] [INFO] : Pushwoosh: x [INFO] : Pushwoosh: | Pushwoosh request: [INFO] : Pushwoosh: | Url: https://xxxxxxxx.api.pushwoosh.com/json/1.3/pushStat [INFO] : Pushwoosh: | Payload: {"request":{"v":"4.12.2","device_type":3,"application":"xxxxxxx","hwid":"xxxxxxxxxx","hash":"B","userId":"xxxxxxxxxx"}} [INFO] : Pushwoosh: | Response: {"status_code":200,"status_message":"OK","response":null} [INFO] : Pushwoosh: x [INFO] : Pushwoosh: [RequestManager] [INFO] : Pushwoosh: x [INFO] : Pushwoosh: | Pushwoosh request: [INFO] : Pushwoosh: | Url: https://xxxxxxxx.api.pushwoosh.com/json/1.3/applicationOpen [INFO] : Pushwoosh: | Payload: {"request":{"device_type":3,"jailbroken":1,"userId":"xxxxxxxxx","android_package":"com.xxxxxxxxxx","idfa":"xxxxxxxxx","timezone":3600,"v":"4.12.2","app_version":"1.0.9","device_name":"Phone","device_model":"Samsung SM-G920F","os_version":"7.0","language":"it","application":"xxxxxxxxxxxxx","hwid":"xxxxxxxxxxxxx"}} [INFO] : Pushwoosh: | Response: {"status_code":200,"status_message":"OK","response":null} [INFO] : Pushwoosh: x

DimanAM commented 7 years ago

Still cannot reproduce. onPushOpened (at least in sample project) works correctly even on 6.0.2.GA. According to your log some messages with DEBUG level are missing. Try increasing log level. I also recommend using standalone adb logcat or pidcat tools.

wfhm commented 6 years ago

@gioggio79 is this issue still persistent?

gioggio79 commented 6 years ago

Sorry, I don't know. We have upgraded project on Ti sdk 6.1.1 and all work fine.

wfhm commented 6 years ago

@gioggio79 Thank for a revert!

Since we cannot reproduce the issue and the initial reporter does not face it anymore, the issue is closed.