arleyandrada / PushClient

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

PushClient question #46

Closed somefakeuser closed 9 years ago

somefakeuser commented 9 years ago

Hi, I have a question, when the application is completly closed(it's dead not sleep), how can I handle the push notifications? Actually any of callbacks are triggered when the application is closed and a notification is sent.

I really don't understand when MODE_CLICK & MODE_ACTION are triggered, May you explain to me?

Thanks.

somefakeuser commented 9 years ago

Should I register the device each time that close and open the app? When I kill the app and open again and send a message the callbacks don't not work.

arleyandrada commented 9 years ago

Both in iOS or Android, when a push notification is arrived with app "not in foreground" and with at least an "alert attribute", an message is always automatically showed in notification tray. When user clicks on that message, your app is started and a CLICK callback is fired, regardless if it is stopped, killed or running.

The ACTION callback is only related to the iOS 8 new feature. http://www.appcelerator.com/blog/2014/09/new-in-sdk-3-4-ios-8-interactive-notifications/

With Android, when the app is in background (not stopped or killed) an BACKGROUND callback is fired with all payload data.

With iOS, if you enable the iOS 7 "background notification" feature, when the app is in background or stopped (not killed) an BACKGROUND callback is fired with all payload data. When your app is killed the iOS 7 "background notification" feature do not work (existing known bug). http://hayageek.com/ios-silent-push-notifications/

Both in iOS or Android, when the app is in foreground, an FOREGROUND callback is fired and none message is showed in notification tray.

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

That is all.

Regards,

Arley

somefakeuser commented 9 years ago

Thank you for your quick answer, and excelent explanation, I get it all, except for "alert attribute", it sounds like a some data required from incoming notification payload, am I right? I really didn't know that the module was able to generate notifications on notification tray, in foreground and background callbacks I manually generate a notification, but I would like know how to perform that when the app is not live.

Thanks.

arleyandrada commented 9 years ago

By default, and imposed by iOS, if you send a payload data with an "alert" attribute... when is not in foreground... an notification is automatically generated and showed in notification tray.

By default, and imposed by iOS too, if your app is in foreground and do you want to show an notification you need to do it by your self.

If your app is not automatically showing notifications (not in foreground), check your sent payload data and share a log of your received payload from callback event with me.

Regards,

Arley

somefakeuser commented 9 years ago

This would be a payload from server(Amazon SNS service)

 {"gcm":{"messageType":"gcm"},"collapse_key":"do_not_collapse","from":"1053361210584","default":"test"}

I suppose that some data is missing there.

arleyandrada commented 9 years ago

I will build a special version to you. Amazon SNS put everything in an "default" attribute.

somefakeuser commented 9 years ago

You're right, Amazon SNS handles the payload using default key, I'm really thankful for your help.

arleyandrada commented 9 years ago

Try again with the attached module.

Send an payload like that:

{ "alert" : "Hello World!", "vibrate" : true, "sound" : "default" }

Regards,

Arley

[ attachment removed ]

arleyandrada commented 9 years ago

Did you calling the unregisterPush method and the method registerPush one right after the other?

Both are async methods and there is no callback to unregisterPush. If you really need to do this, try to call the registerPush method after passed some seconds.

By the way, for the correct operation of my module you need to run the registerPush method at every app start, even if the device has been registered previously.

If the problem persists, maybe you can share your entire project with me, or an minimal version of it.

Regards,

Arley