Notification Listener while app is in background not called.

How it really works is that the operating system manages notifications and updating app badge numbers.  If you force quit your Skype and Facebook apps via iOS’ task manager (ie: double tap the home button, tap and hold app, and tap its [x] button), notice that you’ll still receive push notifications targeted for those apps and have their app badge numbers updated, even while they are *not* running in the background.  This proves that it’s the operating system that is applying the badge numbers.  Those apps are never started in the background when a notification is received… and that’s the main point I’m making.  iOS apps are *never* notified when a notification triggers while the app is running in the background.  iOS apps are only notified when the app is running in the foreground or when the end-user taps on a notification, which launches the iOS app.

Anyways, I hope this helps.

Peach… i think its understandable ppl dont trust in any of that ‘its in the bug list’

its now… aeh how many years not working???

will see if you answer… would be great :slight_smile:

Chris,

A notification listener cannot be invoked while your app is in the background on iOS.  This is an iOS limitation and there is nothing that we can do about this.  Apple’s native “didReceiveLocalNotification” and “didReceiveRemoteNotification” listeners in Objective-C do not get called.  So, there is literally nothing we can do about it.

The only solution is for you to predict what the badge count is ahead of time when scheduling a notification.  I agree that it’s very inconvenient and it would have been better if it incremented the badge count instead, but unfortunately, that’s by Apple’s design.
 

I double checked your bug reports filed in our system and noticed that we did respond to you in July of last year.  I apologize if you’ve missed it.  In any case, we’re not classifying this a bug since it is an iOS limitation.

Hi Joshua,

finally an answer :slight_smile: thank you.

Anyhow I just wonder how other apps do like SYPE, updating the Badge when a message comes in, when the app is in the background. It could only happen with multitasking or anything like that.

So there is nothing we can do with Corona like that even in the future. To update the badge with something that happens even the app is not in the foreground.

OK… no bug :slight_smile: accepted…

anyhow a solution to get something like mail/skype anything that updates the badge even while not in the foreground is appreciated (any plans?)

greets

chris

Hi Joshua,

finally an answer :slight_smile: thank you.

Anyhow I just wonder how other apps do like SYPE, updating the Badge when a message comes in, when the app is in the background. It could only happen with multitasking or anything like that.

So there is nothing we can do with Corona like that even in the future. To update the badge with something that happens even the app is not in the foreground.

OK… no bug :slight_smile: accepted…

anyhow a solution to get something like mail/skype anything that updates the badge even while not in the foreground is appreciated (any plans?)

greets

chris

Hi Joshua,

finally an answer :slight_smile: thank you.

Anyhow I just wonder how other apps do like SYPE, updating the Badge when a message comes in, when the app is in the background. It could only happen with multitasking or anything like that.

So there is nothing we can do with Corona like that even in the future. To update the badge with something that happens even the app is not in the foreground.

OK… no bug :slight_smile: accepted…

anyhow a solution to get something like mail/skype anything that updates the badge even while not in the foreground is appreciated (any plans?)

greets

chris

On iOS, notifications are managed by the operating system, not the app.  Notice that when you force quit an app such as SYPE, its notifications are still displayed in the status bar and continues to receive push/local notifications and updating its badge number.  This is because the operating system is handling the notifications and setting the badge number.  Your notification has to tell the OS what to set the badge number to.  It does not increment the badge count.

So, what you are expected to do when scheduling a notification is to read the current badge count of you app via native.getProperty(“applicationIconBadgeNumber”), add 1 to that badge number, and then schedule the notification.

http://docs.coronalabs.com/api/library/native/getProperty.html

When the end-user taps on a notification, you’ll receive a “notification” event (if a listener is enabled), which is your opportunity to clear the badge count or decrement it by 1, cancel the existing scheduled notification, and then re-schedule it with an updated badge count.

http://docs.coronalabs.com/api/event/notification/index.html

http://docs.coronalabs.com/api/library/system/cancelNotification.html

I agree that this is a really inconvenient way of handling badge numbers, but that’s just the way Apple made it.

Apple documents the above and their suggestions on how to handle the badge count via the link below for their native APIs, if you think it’ll help.

http://docs.coronalabs.com/api/library/system/cancelNotification.html

Hi Joshua,

thanks for your detailed answer.

One thing I still dont get. You say Notifications are handled by the OS not the app. Till here I got it and said, ok bad luck.

AND THAN you mention Skype?? But Skype is also an App, right?

So how do they and how can I do same? What do they different than my app,

Sorry, i may sound dumb, but really i dont get it.

Or do you like to say. if i code in XCode I can do it, but not through Corona?

thanks chris

Odds are Skype has to set the app badge number ahead of time when posting the notification just like everyone else, unless Apple has given them special privileges to run code in the background, which is extremely rare.  That’s definitely not the case for apps such as facebook, eBay, or the vast majority of apps on iOS.  In any case, my point is that our native Objective-C listeners never get called in the background.  So, there is just no way to do this.  Not even in native code and Xcode.

ok… lets say Corona cant do it, but Facebook Messanger for sure… even if its in the background it always updates the Badge when there are new messages.

same to skype, right?

How it really works is that the operating system manages notifications and updating app badge numbers.  If you force quit your Skype and Facebook apps via iOS’ task manager (ie: double tap the home button, tap and hold app, and tap its [x] button), notice that you’ll still receive push notifications targeted for those apps and have their app badge numbers updated, even while they are *not* running in the background.  This proves that it’s the operating system that is applying the badge numbers.  Those apps are never started in the background when a notification is received… and that’s the main point I’m making.  iOS apps are *never* notified when a notification triggers while the app is running in the background.  iOS apps are only notified when the app is running in the foreground or when the end-user taps on a notification, which launches the iOS app.

Anyways, I hope this helps.