Notification Listener while app is in background not called.

Hi there,

as spoken with peach (Ansca Team) here a bug report for
repeating Notifications.

https://developer.anscamobile.com/forum/2011/12/11/set-icon-badge-while-notification-please-help#new

When in Background, Only the first notification activates
the notificationlistener and gives a console output.

So i can’t create new notifications. It should just work
as the app is in the foreground

io.output():setvbuf("no")  
display.setStatusBar( display.HiddenStatusBar )  
   
   
print ("---- Repeated Notification")   
-- Options for iOS   
local options = {  
 alert = "Wake up!",  
 badge = 2,  
 custom = { foo = "bar" }  
}  
   
local utcTime = os.date( "\*t", os.time() + 10 )  
local notification = system.scheduleNotification( utcTime, options )  
   
local listener = function( event )  
 print( event.name ) -- ==\> "notification"  
 print( event.custom.foo ) -- ==\> "bar"  
 local utcTime = os.date( "!\*t", os.time() + 10 )  
 local notification = system.scheduleNotification( utcTime, options )  
   
end  
   
Runtime:addEventListener( "notification", listener )  

greets
chris
[import]uid: 4795 topic_id: 19169 reply_id: 319169[/import]

Hey again Chris,

Can you please file a bug as well, then post the # here?

http://developer.anscamobile.com/content/bug-submission

(Makes it easier for the team to keep track of it.)

Peach :slight_smile: [import]uid: 52491 topic_id: 19169 reply_id: 74113[/import]

any updates on that?

chris
[import]uid: 4795 topic_id: 19169 reply_id: 105769[/import]

Hey Chris, you still haven’t told me the bug/case # - let me know and will look up the current status for you.

Peach :slight_smile: [import]uid: 52491 topic_id: 19169 reply_id: 105809[/import]

Hi Peach,

I made one bug report on 13th of January already #11536
and now yesterday another one #14177

thanks
chris
[import]uid: 4795 topic_id: 19169 reply_id: 105860[/import]

Case #14177 was tested and confirmed on build 806 and has now been assigned - so basically we can reproduce it and someone is looking into it :slight_smile: [import]uid: 52491 topic_id: 19169 reply_id: 105963[/import]

that sounds great… because when its possible to generate new
notifications in the background while a previous notification is called…
it opens lots of possibilities.

also little wondering as you say its confirmed as a bug as you can reproduce…
but in the same time it would mean that features needs kind a multitasking ability (running in the background) and as i understood now in the meantime corona does not do that.
anyhow… how ever you solve it… would be great… as it would allow to do apps like
Facebook or Skype… that gets data in the background and we could show results in the bage icon for example (like new messages or posts)

is there any way i can follow that case myself, to see the actual status?
all the best
chris
[import]uid: 4795 topic_id: 19169 reply_id: 106105[/import]

Currently you cannot follow this, no (we hope to work on that soon, make bugs easier to track, etc) - although if you need info you can reply to the email you got when you filed the bug and the case will be updated with your email.

Peach :slight_smile: [import]uid: 52491 topic_id: 19169 reply_id: 106153[/import]

heeelloooooooooo any news on that, please can you look into the bug case

thx
chris
[import]uid: 4795 topic_id: 19169 reply_id: 113822[/import]

You are bumping two threads instantaneously about the same thing - both starting with “heelloooooooo” or “.haaalllllllo” - please, don’t do that. Just bump one unless both are *different*.

As to the bug, just looking it up - it was last updated today/yesterday (depending on your time zone) by you with the update; “any news on that???”

  • I expect you will get a reply from whoever it is assigned to this week when they see your message. [import]uid: 52491 topic_id: 19169 reply_id: 113889[/import]

thanks.
but please also understand us users come unpatient when
we have to wait for “MONTH” (in that case 6 Month!) to get a feature working that should work from the beginning.
otherwise please don’t do that announcing a feature that does not work for months or never.
Like the “Audio GetTunerVolume” (not working since more than a year)

when ansca say …“that will work soon” or something like that, it prevents us from going to another developing platform. but for sure there is an expectation that soon is ‘soon’ in days, weeks.

sorry to put several topic in same thread, but there are too many open construction sides and
i guess not me from all developers would prefer less new features but the official one WORKING
as they should.

I also understand your position, you are just one, so this is addressed to the whole team.
With all respect and regards
Chris
[import]uid: 4795 topic_id: 19169 reply_id: 113891[/import]

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?