Closed minimedj closed 9 years ago
Hi,
Add your notification event listener and call register. The notification that started the application will be dispatched immediately after calling register (if the application was started from a notification).
Some code:
PushNotifications.service.addEventListener( PushNotificationEvent.NOTIFICATION, notificationHandler );
PushNotifications.service.register( GCM_SENDER_ID );
Then in your handler:
private function notificationHandler( event:PushNotificationEvent ):void
{
// Handle your start up notification
}
I read in FAQ here (https://docs.google.com/document/d/1C3LltzyzZX96cyq69Lz1vuEVxD4erQhTwyBQeGrjCTs/pub):
Will the extension help to open the mobile app in a specific place once the notification received?
This is unavailable at the moment. Due to the way native extensions are implemented, we don't have access to the application startup options so we can't receive application startup notifications. You'll need to check your server for notifications at startup.
So, for me it is still unclear where it is limitation of your ANE, or of AIR platform itself?
Thanks for pointing that out, I figured out a way around it a while ago, so I'll make sure that documentation gets updated.
@marchbold thank you for your answer but it not relevant for me. As I wrote I have no problems with notifications if my app is running. I only have problems with payload when I am starting my app from push notification.
@marchbold so, please give me a clear answer: can I get PUSH's payload when I start app from PUSH?
Hi,
I did understand your situation and the answer above is for when an application is started from a push notification. The register function checks for a startup notification and dispatches the event immediately.
Regards, Michael
@marchbold My situation is the following:
Another scenario:
Any ideas why it is like this?
Are you using the method I described above?
Yes. 100% the same code as you provided. After some debugging I see that the problem is that event.data == null
in this callback handler:
private function notificationHandler( event:PushNotificationEvent ):void
{
// Handle your start up notification
}
So I get:
ERROR:: Error #1009: Cannot access a property or method of a null object reference.
Can you provide an example of the payload you are using?
Also would be helpful to know the platform you are using, and can you obtain the device logs when you receive and click on a notification?
@marchbold To make it 100% clear that this is issue of ANE I will me a demo project. As soon as I nail the problem I will report it here. Thank you very much for your help!
@marchbold I confirm that everything works as expected. Thank you very much.
Glad to hear! Would you mind sharing with everyone what your problem was in case someone else comes across this? Cheers
Hi guys, I send PUSH from server with some payload. How do I get it is I start app from PUSH (I click on the push on device and app starts)?
p.s. If app is started and minimized - I have no problem with getting payload.