arleyandrada / PushClient

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

PushClient Problem with Click events #30

Closed somefakeuser closed 9 years ago

somefakeuser commented 9 years ago

Hi Supportteam,

I bought your module and got it running with your parse example.

Pushes are working, but Click-Callback-Events are never deleted from my phone. Every time I open my app, I receive the first click event, that was generated. Even if I push new notifications, the notification is uptodate, but on clicking it I receive the old click event. I habe to restart my phone to get rid of the old click event.

Do you have any suggestions on fixing this behaviour?

arleyandrada commented 9 years ago

Hi,

Which Titanium SDK version, PushClient module version, Platform and payload data are you using?

Regards,

Arley

arleyandrada commented 9 years ago

Hi,

It's required to call the registerPush method from my module at every app start, regardless if the device is already registered.

Put the method call at alloy.js or at the main controller for alloy projects or at app.js for classic projects.

Regards,

Arley

somefakeuser commented 9 years ago

Hi Arley,

thanks for the quick response! I am using Titanium 3.4.0 (no pending updates) PushClient 1.5 Android 4.4.4 (HTC M8) Payload via Parse: just a string, no json

Regards

somefakeuser commented 9 years ago

Hi Arley,

I tested your code on Android 4.1.2 (Samsung 9100) Now I only get ONE click event - which ist correct- , but on every push notification it is the same. The first one that was sent to the device.

To clarify:

First Notification send via parse: "Test1" Notification received on device: "Test1" Click event in app: "Test1"

Second Notification send via parse: "Test2" Notification received on device: "Test2" Click event in app: "Test1"

Third Notification send via parse: "Test3" Notification received on device: "Test3" Click event in app: "Test1"

I can send you my Ti project with your code if necessary - but is contains only your code in a newly created Project.

Perhaps related: Registration is successful but I get the following error on 4.1.2: [ERROR] : SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

Do I have to do anything within the click event handler to get rid of old events? Now I use your code to show an alert.

somefakeuser commented 9 years ago

Hi Arley,

So please answer these questions:

Did you understand the error condition? There is no problem with the registration or the push notification delivery to the device. I get old click events. The notification does not match the event ("test5" in notification and "test1" in event from four pushes earlier). I assume that' s not as designed.

Anything I can do to track down the problem? Anthing I have to do with the event? Do I have to register for the events on every app start? It looks like it is cached within your module and delivered over and over again until reboot.

Regarding your customers: If they only want their app to open, it works fine! The content of the event is wrong. And I need the correct content as a deep link.

I send you the code from the Test project. I used Hello world, added your module and put your code into alloy.js

I tested on two devices with 4.4.4 and 4.1.2. and get the wrong event data!

Regards

arleyandrada commented 9 years ago

Hi,

Did you understand the error condition?

YES, but I can't reproduce the error yet.

Anything I can do to track down the problem? Anything I have to do with the event? Do I have to register for the events on every app start?

YES, without registering for the events on every app start you can't handle the callback from click, foreground or background... and without call the registerPush method the module can't handle the notification correctly... but apparently it's right in your app.

My own projects and many others from my customers need and use more than "open the app" from notification click.

Please, try to build and run my attached sample project Clique Here in your environment and your devices. Let me know if it works for you.

Regards,

Arley

somefakeuser commented 9 years ago

Hi Arley,

thanks for the clarification.

I installed your app with the same results. Registration succeeded. First push to foreground was ok. Second push to background was ok. Third push as in screenshots (Notification "test3"; Registration ok, Click event "test2" from previous push)

Thanks for the effort - I hope you have an idea to fix it!

Regards

screenshot_2014-11-08-20-02-25 screenshot_2014-11-08-20-02-37 screenshot_2014-11-08-20-02-43 screenshot_2014-11-08-20-02-49

arleyandrada commented 9 years ago

Hi,

Have you found a bug in my module! I'm working in a fix to it right now.

Thanks,

Arley

somefakeuser commented 9 years ago

Hi Arley,

thanks, great news! Looking forward to it!

Regards

arleyandrada commented 9 years ago

Hi,

I just released a new fixed module version. Remove previous version (1.5) and add the new version (1.6) in your app. Remember to clean your project before to build it again.

Please let me know if it works fine to you.

Thanks,

Arley

somefakeuser commented 9 years ago

Hi Arley,

thanks for the quick fix!

Now I have the following situation:

The pushes (notifications and clicks) work on 4.1.2 and 4.4.4.

But on both platforms I get the last click event every time I open the app. Is that correct behaviour?

On 4.1.2 I have two issues:

The first GCM registration attempt after installation fails:

Module: Loading module: parse -> Resources/parse.js
[INFO] :   registerPush...
[DEBUG] :  OpenGLRenderer: Enabling debug mode 0
[DEBUG] :  Window: Checkpoint: postWindowCreated()
[DEBUG] :  dalvikvm: GC_FOR_ALLOC freed 901K, 16% free 12576K/14919K, paused 36ms, total 36ms
[WARN] :   TiVerify: (Timer-0) [5015,5015] Verifying module licenses...
[INFO] :   eventError:{"type":"PushClient_Error","source":{"bubbleParent":true,"apiName":"Ti.Module","invocationAPIs":[],"_events":{"PushClient_Success":{},"PushClient_Error":{},"PushClient_Callback":{}}},"bubbles":false,"success":false,"code":3,"error":"SERVICE_NOT_AVAILABLE","cancelBubble":false}
[INFO] :   ALERT: (KrollRuntimeThread) [1100,6115] Error:
[INFO] :   ALERT:
[INFO] :   ALERT: Unable to register this device
[INFO] :   ALERT:
[INFO] :   ALERT: SERVICE_NOT_AVAILABLE
[INFO] :   TiVerify: (Timer-0) [172,6287] Succesfully verified module licenses
[WARN] :   ResourceType: Failure getting entry for 0x010802c0 (t=7 e=704) in package 0 (error -75)

The retry works. Any ideas? Or should I catch the error and retry registration.

After starting the app and closing the alerts I get the following error in the log:

[INFO] :   ALERT: (KrollRuntimeThread) [1478,2192] Parse API Success:
[DEBUG] :  HTTPClient: The persistent handle is disposed.
[INFO] :   ALERT:
[INFO] :   ALERT: {"channels":[],"deviceToken":"APA91bFDhKuqwMlirxrryyYh1ovr0XK8KwIDjFwRO4K_m8aok5k7BDSw7ZNxHXvSacc37JpOBph97tzO0mmE-xMki7DRx4BbIzOM-z1pXCvxbAFUljgOMC8NIn02EiDbB-9oESL47PFB7bEM7MPJGFr5tF2LOlar4_-VC9D9fu_ZF6RkRMxZU9I","deviceType":"android","installationId":"0bae41ec-0b75-47c4-bbaf-9fc904aba00d","pushType":"gcm","createdAt":"2014-11-09T08:29:15.587Z","updatedAt":"2014-11-09T08:31:41.207Z","objectId":"NlPP7pgpya"}
[WARN] :   ResourceType: Failure getting entry for 0x010802c0 (t=7 e=704) in package 0 (error -75)
[ERROR] :  SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[ERROR] :  SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

Everthing seems to work. Is it related to your module?

I hope these issues can be resolved too.

Regards

arleyandrada commented 9 years ago

Hi,

But on both platforms I get the last click event every time I open the app. Is that correct behaviour?

No, It's not an expected behaviour. I could not reproduce this error. Can you explain with detailed steps what are you doing?

The first GCM registration attempt after installation fails. The retry works. Any ideas? Or should I catch the error and retry registration.

Appears to be a problem related to Internet connection. Yes, you can catch the error and retry many times as needed.

After starting the app and closing the alerts I get the following error in the log. Everthing seems to work. Is it related to your module?

No, there is nothing related to SpannableStringBuilder within my module.

Regards,

Arley

somefakeuser commented 9 years ago

Hi Arley,

I am not able to test as Parse ist not working. My pushes don't get send.

I had the behaviour using your test app. After first click event occured I closed the alert und the app. After opening and successful registration I got the event again. Tried four times - every time the same event.

I will retry when Parse is working.

Regards

somefakeuser commented 9 years ago

Hi Arley,

I tried to change the ParseGCMSenderId to my client's. That's why parse did not work.

How can I use my client's Google project?

somefakeuser commented 9 years ago

Hi Arley,

forget my last mail - I misunderstood the concept. The GCM-ID is from Parse and not from you...

I think I can work around the last issue - but perhaps you can reproduce it!

arleyandrada commented 9 years ago

With Parse.com you need to use their id. It's not a restriction from my module. It's a Parse restriction.

somefakeuser commented 9 years ago

Hi Arley,

I have one question regarding the events.

Is it possible to send a log request to my server as soon as the device gets the push? If I place the call within the click or background handler it gets executed only if the notification is clicked or the app opened. Is that right?

Thanks for your support!

Regards

arleyandrada commented 9 years ago

Hi,

Yes, you can! Exactly as you think.

Regards,

Arley

somefakeuser commented 9 years ago

Hi Arley,

sorry to bother you again, but I don't understand where to put my logging request?

I put a logging statement everywhere, but nothing is logged if a push arrives - only if notification is clicked or app opened:

    } else if (event.mode == PushClient.MODE_FOREGROUND) {
    Ti.API.info('***FOREGROUND:' + JSON.stringify(event));
    alert('Callback in Foreground:\n\n' + JSON.stringify(event.data));
        // Push data received with app in foreground
    } else if (event.mode == PushClient.MODE_CLICK) {
Ti.API.info('***CLICK:' + JSON.stringify(event));
        alert('Callback from Click:\n\n' + JSON.stringify(event.data));
        // Push data received when user clicks in notification message
    } else if (event.mode == PushClient.MODE_BACKGROUND) {
Ti.API.info('***BACKGROUND:' + JSON.stringify(event));
        // Requires set remote-notification UIBackgroundModes in tiapp.xml
        PushClient.endBackgroundHandler(event.data.handlerId);
        // Put the application back to sleep before any UI interations
        alert('Callback from Silent:\n\n' + JSON.stringify(event.data));
        // Push data received with app in background
    }

Regards

arleyandrada commented 9 years ago

You can log only the available events: Foreground, Background or Click.

No event is fired when the notification arrives if the app is not running or is killed.