freshplanet / ANE-Push-Notification

Air Native Extension (iOS and Android) for Push Notification
Apache License 2.0
205 stars 104 forks source link

onIncomingNotifiation nonrespondent when app is deactivated #8

Closed matusz13 closed 7 years ago

matusz13 commented 11 years ago

I'm sure there are a few ways to skin this cat but I'm wondering if anyone has run into this.

I'm trying to make a badge count for notifications and I've noticed that when the app is deactivated (ideally when you'd want to display badges) - so are the listeners. Is there any way to work around this? Anything I'm missing?

-Matt

titi-us commented 11 years ago

A few points regarding the iOS badge count:

matusz13 commented 11 years ago

Ok, I believe my app to be running in the background and I attempt to set the badge with the following (badgeCount being an integer) - I see the notification message but no badge.

protected function onIncomingNotifiation(e:PushNotificationEvent):void{ badgeCount++; i_apns.setBadgeNumberValue(badgeCount); }

titi-us commented 11 years ago

Your function onIncomingNotification will be called only if you've received a push notification and your app is running in the foreground.

If your application is running in the background, the only way to set the badge count is through the payload of the push notification (the one you are sending with your server): { "aps" : { "alert" : "name of the notification.", "badge" : the_number_you_wanna_set, }, } where the_number_you_wanna_set is the number that's gonna display when this push notification is received by the device.