Oh good! I’m glad it’s working for you! [import]uid: 32256 topic_id: 34526 reply_id: 138373[/import]
Hi Joshua,
jumping in on this thread for a second, since it’s sort of related to our issue.
Every time the app is started, old notifications floods the status bar. How can we make sure a notification is shown only once? Our users also wants the notifications to be deleted automatically, and I assume other android apps works like that. How do we enable that?
Another weird thing is that if we delete notifications manually from the list, and then start up the app, notifications pop back up in the status bar - but they’re not visible in the list. Why is that?
Thanks! [import]uid: 21746 topic_id: 34526 reply_id: 140608[/import]
Hello Haakon,
On Android, we have to set up a “broadcast receiver” to listen for when a notification gets tapped on or removed from the status bar. This informs Corona to remove the notification from Corona’s internal configuration file so that it won’t reappear the next time the app is started up.
So, it sounds like this isn’t working for you anymore, right?
If so, then I suspect our boradcast receive settings are missing in your AndroidManifest.xml file. It should appear as follows inside of the “application” tag block…
[lua]
[/lua]
I recommend that you have a look at one of our Corona Enterprise sample project’s AndroidManifest.xml file. You may want to use a diff tool to compare our newest AndroidManifest.xml file with your own to make sure nothing is missing.
Also, note that the AlarmManagerBroadcastReceiver is only used for local/scheduled notifications, not push notifications. So, you can omit it from your manifest is you want, but it’s harmless to include it. The StatusBarBroadcastReceiver is absolutely needed though. The “com.ansca.corona.CoronaService” is needed as well in order to keep status bar notifications alive after the end-user backs out of your app too because it prevents the OS from quitting your app while it is in the background.
Anyways, I hope this helps. [import]uid: 32256 topic_id: 34526 reply_id: 140656[/import]
And how about icons for notifications on enterprise?
Here is what was said for the regular corona…
Nevermind -->
https://developer.coronalabs.com/forum/2013/01/16/custom-android-push-notification-status-bar-icon [import]uid: 169919 topic_id: 34526 reply_id: 140961[/import]
You got it. Follow the instructions you see in this link…
https://developer.coronalabs.com/forum/2013/01/16/custom-android-push-notification-status-bar-icon
By the way, that’s how you would normally override icons/resources belonging to a library when doing native Android development. [import]uid: 32256 topic_id: 34526 reply_id: 140969[/import]
Hi Joshua,
jumping in on this thread for a second, since it’s sort of related to our issue.
Every time the app is started, old notifications floods the status bar. How can we make sure a notification is shown only once? Our users also wants the notifications to be deleted automatically, and I assume other android apps works like that. How do we enable that?
Another weird thing is that if we delete notifications manually from the list, and then start up the app, notifications pop back up in the status bar - but they’re not visible in the list. Why is that?
Thanks! [import]uid: 21746 topic_id: 34526 reply_id: 140608[/import]
Hello Haakon,
On Android, we have to set up a “broadcast receiver” to listen for when a notification gets tapped on or removed from the status bar. This informs Corona to remove the notification from Corona’s internal configuration file so that it won’t reappear the next time the app is started up.
So, it sounds like this isn’t working for you anymore, right?
If so, then I suspect our boradcast receive settings are missing in your AndroidManifest.xml file. It should appear as follows inside of the “application” tag block…
[lua]
[/lua]
I recommend that you have a look at one of our Corona Enterprise sample project’s AndroidManifest.xml file. You may want to use a diff tool to compare our newest AndroidManifest.xml file with your own to make sure nothing is missing.
Also, note that the AlarmManagerBroadcastReceiver is only used for local/scheduled notifications, not push notifications. So, you can omit it from your manifest is you want, but it’s harmless to include it. The StatusBarBroadcastReceiver is absolutely needed though. The “com.ansca.corona.CoronaService” is needed as well in order to keep status bar notifications alive after the end-user backs out of your app too because it prevents the OS from quitting your app while it is in the background.
Anyways, I hope this helps. [import]uid: 32256 topic_id: 34526 reply_id: 140656[/import]
And how about icons for notifications on enterprise?
Here is what was said for the regular corona…
Nevermind -->
https://developer.coronalabs.com/forum/2013/01/16/custom-android-push-notification-status-bar-icon [import]uid: 169919 topic_id: 34526 reply_id: 140961[/import]
You got it. Follow the instructions you see in this link…
https://developer.coronalabs.com/forum/2013/01/16/custom-android-push-notification-status-bar-icon
By the way, that’s how you would normally override icons/resources belonging to a library when doing native Android development. [import]uid: 32256 topic_id: 34526 reply_id: 140969[/import]
This isn’t really about the setup, but it’s about push notifications on Android so this seemed like a good place to post. Is it really necessary to actually show the push notification when the game is active?
This is not about the lua event listener, that behaves just like expected.
But there’s no need to add the notification to the Android statusbar if the game is active. Now, we catch the event and cancel it if the game is active, but the notification still shows in the statusbar before being cancelled a split second later.
This is sort of not wanted in a turn-based game, where the players get notified for every move an opponent makes.
The game, being a real-time game, handles this on its own when it’s open. Isn’t it possible to make this work just like on iOS?
@kimruben, I feel the same way about it, and I posted somewhat similar thoughts here:
http://forums.coronalabs.com/topic/26257-push-notifications/page-4
After reading through that thread, I sort of came to conclude that there probably isn’t an easy way at this time not to show these icons lining up on status bar… A bit annoying but I guess we’d have to hope that the user wouldn’t mind pulling down the status bar and remove all these icons with a tap on a button on the menu… But then I wonder if it would irritate the users too much, and if it ends up being negative experience, maybe we don’t want to use push notification on Android device for a game that could easily line icons up one after the other quickly. I dunno. After working out all the details, I don’t feel like removing the feature from the game, but if it impacts too negatively, we’d have to cut the loss and move on.
BTW, I just noticed you are Enterprise user. You might be able to control it in greater detail than pro/indie users could. (And wow, I just realized this was Enterprise forum. Sorry about that.)
Naomi
On Android, you can clear the notification you just received in-app by calling the “system.cancelNotification()” function with no arguments. This clears both remote and local notifications. The Android handling is actually better than iOS’ because you at least have the option to leave the received notification in the status bar if you don’t want to bug the user about it in-app. iOS is the one with the limited notification handling.
Ah, okay, thank you so much, Joshua. I failed to find the API call – and believe me, I looked and looked.
Thanks again!
Naomi
Hey Joshua I know, as I described we already cancel the notification in-app when the app is active.
But, still the notification flashes in the statusbar for a brief second before being cancelled. What I’m askin for is if it isn’t possible to have the Android notification behaviour equal the iOS behaviour while the app is active?
Meaning that you in your GCM Broadcast Receiver check if the app is active or not, and based on that decide whether to show it in the statusbar or not.
The event should still fire in the lua listener though.
It is certainly possible to change the Android behavior to match iOS’. I just think Android’s current implementation is better because the notification alert behaves consistently in and out of the app. But that said, I’ll note your request down to discuss with the rest of the team later.
This isn’t really about the setup, but it’s about push notifications on Android so this seemed like a good place to post. Is it really necessary to actually show the push notification when the game is active?
This is not about the lua event listener, that behaves just like expected.
But there’s no need to add the notification to the Android statusbar if the game is active. Now, we catch the event and cancel it if the game is active, but the notification still shows in the statusbar before being cancelled a split second later.
This is sort of not wanted in a turn-based game, where the players get notified for every move an opponent makes.
The game, being a real-time game, handles this on its own when it’s open. Isn’t it possible to make this work just like on iOS?
@kimruben, I feel the same way about it, and I posted somewhat similar thoughts here:
http://forums.coronalabs.com/topic/26257-push-notifications/page-4
After reading through that thread, I sort of came to conclude that there probably isn’t an easy way at this time not to show these icons lining up on status bar… A bit annoying but I guess we’d have to hope that the user wouldn’t mind pulling down the status bar and remove all these icons with a tap on a button on the menu… But then I wonder if it would irritate the users too much, and if it ends up being negative experience, maybe we don’t want to use push notification on Android device for a game that could easily line icons up one after the other quickly. I dunno. After working out all the details, I don’t feel like removing the feature from the game, but if it impacts too negatively, we’d have to cut the loss and move on.
BTW, I just noticed you are Enterprise user. You might be able to control it in greater detail than pro/indie users could. (And wow, I just realized this was Enterprise forum. Sorry about that.)
Naomi
On Android, you can clear the notification you just received in-app by calling the “system.cancelNotification()” function with no arguments. This clears both remote and local notifications. The Android handling is actually better than iOS’ because you at least have the option to leave the received notification in the status bar if you don’t want to bug the user about it in-app. iOS is the one with the limited notification handling.
Ah, okay, thank you so much, Joshua. I failed to find the API call – and believe me, I looked and looked.
Thanks again!
Naomi
Hey Joshua I know, as I described we already cancel the notification in-app when the app is active.
But, still the notification flashes in the statusbar for a brief second before being cancelled. What I’m askin for is if it isn’t possible to have the Android notification behaviour equal the iOS behaviour while the app is active?
Meaning that you in your GCM Broadcast Receiver check if the app is active or not, and based on that decide whether to show it in the statusbar or not.
The event should still fire in the lua listener though.