Not that I’m aware of.
Hey,
So this is my code:
local function onNotification(event) if event.type == "remoteRegistration" then app.modules.coronaCloud.registerDevice( event.token ) else -- notification received notificationEvent() end end Runtime:addEventListener( "notification", onNotification )
Do I have to add something, because my notifications keep showing up in the notification bar and the app doesn’t remove them.
I am testing on Android 4.0.4
Hey Joshua,
Just wanted to stop by and say that the notification feature is working like a charm!
Cheers
Great! Happy to help!
Hi Rob,
I have the feeling that I am missing something here…
If my app is active and I receive a notification, my app reacts to the notification. For me the proof that I succesfully cope with the notifications. However if I quit my app afterwards the notification still shows in the statusbar of the Android OS.
Am I missing something? Some special configuration with my launchArgs?
I really haven’t got a clue…
Thanks in advance
Qwertier
This is by design. Notifications on Android can only be removed by the end-user or when you call the system.cancelNotification() function without any arguments.
http://docs.coronalabs.com/api/library/system/cancelNotification.html
Awesome that’s exactly what I needed!
The system.cancelNotification() call removes all notifications perfectly fits my needs. One thing though does the call also remove all the local notification event that still have a timer on them?
Thanks Joshua
Cheers,
Qwertier
EDIT: Is it possible to somehow group the notifications together, like whatsapp for example (you have 3 messages from 2 contacts), while my application is suspended?
The system.cancelNotification() removes *all* notifications that belong to your app, including local/scheduled notifications. It’s kind of inconvenient in that respect, but iOS has that same limitation. That said, you can still re-schedule your local notification right after clearing them.
Regarding grouping notifications, this is currently not supported. Plus, the Android OS does not do this automatically. Android apps achieve this affect by creating custom views in Java in the statusbar. Or, they just use a normal notification but set a number next to it in the bottom right corner. Currently, this can only be done in Java.
Thanks for your quick reply and information!
Yup, I will just reschedule the local notifications. Any information on whether Corona is going to have support for these features, or haven’t you got a clue
Thanks again
EDIT: Before I forget, is it possible to send *empty* notifications? So that the notification doesn’t show in the statusbar, however it **will** cause my application to receive an update.
>> Any information on whether Corona is going to have support for these features
No plans at the moment, but if there is enough demand for it, then we’ll definitely look into it. Our feature request list can be seen via the link below. Please feel free to add to it or vote up the features that you would like to see.
http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/filters/top
>> is it possible to send *empty* notifications?
On Android, this is definitely possible because the GCM is really just a messaging service. We have to post the notification to the status bar ourselves on the Android side. The only issue is that I don’t think iOS supports this… and we’re mostly focused on making our features cross-platform. Or are you perhaps happy with how iOS handles it now, where if the notification is received while your app is in the foreground, nothing gets posted to the statusbar?
My ideal situation for how push should be have is the following:
App in foreground : receive notification, app knows it needs to update, show nothing or delete notifications from the statusbar [This is working now by calling system.cancelNotification()]
App suspended : receive notification, show in statusbar, best would be to group notifications together to prevent spamming of the user.
About the empty notifications I was confused a bit, I was thinking about a situation where my app was suspended and I would send an empty notification to fire up my up. This is not possible of course and it would be very strange to a user if an app just started itself. For some apps not of course, like Skype or Hangouts for example.
The reason I think it is important to have the grouping feature is that the amout of notifications can quickly add up if a user is playing multiple games at the time. Although I am really looking forward to this feature I think it’s reasonable to add the most requested features first.
Thanks a lot!
Greetz
I think I understand now. You pretty much want iOS like notification grouping.
In order for this to be done automatically, we would have to do our own custom grouping internally in Corona via Java in order to achieve this, since the Android OS doesn’t do this for us. It’s actually quite a bit of work, but we’re willing to do it if there is enough demand.
Now, you may be able to do something yourself. We have an experimental feature that allows you to set the title, message, and number next to every notification on Android. Since it’s experimental, it’s not documented and subject to change, but if you’re okay with it changing in the future, then please feel free to play with it. Details on how to set these properties can be found here…
http://forums.coronalabs.com/topic/34331-custom-android-notifications/?p=181751
So, my idea is that every time your app received a notification event, you can clear all notifications and then post your own group notification where you set the “number” property to the number of unhandled notifications. You can post that group notification by calling system.scheduleNotification() with a zero duration, which causes it to be posted immediately. The downside to this solution is that your app can only do this while it is in the foreground, because your Lua script would have to control this behavior. Corona would just continue to post individual notifications to the status bar while your app is in the background. Not sure if that’ll quite cut it, but that’s the next best thing that I can think of.
Thanks for the ideas Joshua.
My main focus is to get group the incoming notifications together when my app is in the background. This is not possible yet so I will have to wait for that.
One thing, when I was testing the experimental (custom)notification feature It didn’t show any extra info except the title. Might this be due to my Andoid 4.0 version?
Thanks
EDIT: The notification was only showing my application name, I was using the following code and all I got was an empty notification with my app name only
local settings = { alert = { title = "My Title", body = "This is my body text.", number = 5 } } system.scheduleNotification(0, settings)
>> when I was testing the experimental (custom)notification feature It didn’t show any extra info except the title.
Shoot… it’s actually a bug in our code. It used to work, but we broke it when we refactored our code just before the last release (before build #1076). This is super simple for us to fix. I’ll look into having this fixed later this week.
Awesome stuff!
Thanks Joshua
The alert title, body, and number fix will be made available in daily build #1121, tomorrow.
The release notes makes no mention of it because it’s still a semi-secret/experimental feature, but trust me, the fix is there.
Thanks Joshua!
Eagerly looking forward to this feature, very happy with the quick support
Hey Joshua,
Just wanted to stop by and say that the notification feature is working like a charm!
Cheers
Great! Happy to help!
Any news on grouping notifications? This is a huge downside in your Android push implementation. Our games uses push notifications extensively to keep our players updated about changes in their multiplayer games, and the statusbar in Android gets bloated with icons. We receive a lot of complaints about this.