Ok, so I've wrote a small app that receives remote notifications that I handle in didReceiveRemoteNotification and I also check the userDict passed to didFinishLaunch.
However, the notifications is sill listed as "unread" in the notification-center on iOS 5 (there is a tiny blue dot to the left of them). How can I make it so that after a user has clicked a notification it either goes away, or it's marked as read?
I don't think there is a way in iOS 5.0 to only remove one entry. Quoting iOS SDK Release Notes for iOS 5.0:
Springboard
Push and local notifications for apps appear in the new Notification Center in iOS 5. Notification Center displays notifications that are considered "unread.” To accommodate push and local notifications that have no unread status, set your application’s badge count to 0 to clear that app’s notifications from Notification Center.
Related
Right now, my iOS app receives normal (non-silent) push notifications.
iOS device displays notifications as expected.
Now, I want to convert normal notifications to silent by adding "content-available=1" along with all other user visible keys.
To be able to perform bg tasks on notification trigger
My understanding is iOS may not always call didReceiveRemoteNotifications for silent notifications.
My question is would silent notifications will get displayed by iOS (if it contains user visible keys) even if iOS decides not to call didReceiveRemoteNotifications
My expectation is silent notifications should work as is like normal notifications with an advantage of didReceiveRemoteNotifications getting called as and when possible (Best Effort)
I don't want to lose normal notification behavior by switching to silent notifications.
As per this link
For a silent notification, take care to ensure there is no alert,
sound, or badge payload in the aps dictionary. If you don’t follow
this guidance, the incorrectly-configured notification might be
throttled and not delivered to the app in the background, and instead
of being silent is displayed to the user
So if the keys alert, sound and badge are added then that notification will be displayed like a normal push notification.
I'm having a little problem in my app : I use to send local notifications to the user when actions are performed in my app, while it's running in background. Notifications are displayed perfectly in the notification center, but there is no pop-up when the notification occurs.
If I'm right, apps running in foreground can't display pop-up on the user screen (only in the notification center) but when the app is running in background, in fact there is pop-up displayed automatically ?
Thanks for your help !
EDIT : In fact, I'm speaking about a notification banner to be displayed too when the notification appear in the notification center.
When your app will go in background then you will see an immediate notification on your phone but you have to tap that notification to trigger didReceiveLocalNotification delegate.
If you receive local notification in foreground then didReceiveLocalNotification will be triggered automatically.
Above scenario is tested and verified.
Update: You must read this documentation: http://www.thekspace.com/home/component/content/article/62-uilocalnotification-demystified.html
I'm working on a project on iOS 7, 8 that use a lot of notifications (Remote, Local). I have some questions about Local Notification.
I'm using Local Notification to schedule an alarm or a count-down. As I know, the use of NSTimer is not really a good choice since it has only up to 10' in background & if the app process is killed it doesn't work anymore. Local Notification is managed by iOS but I have to accept its alert when the app is not in foreground. There's nothing like silent local notification (local notification without alert, sound or badge and app still knows about it although it's in background). Am I right ?
Let's assume that there're some simple local notifications in Notification Center, scheduled by our app. Normally when I touch on a notification to see it in my app, the others remain present until we interact with them. In some cases that I haven't figured out, all other notifications are removed from the Notification Center. Does anyone encounter this & understand why ?
I find the interactive notification feature in iOS very limited. I want to change the title of a defined UIMutableUserNotificationAction button & add an image for it, like I can do with UIButton. So the question is : Is it possible to customize the UI of an action button ?
Thanks for your help !
Unfortunately there is no correspondence in silent notification using local notifications.
The number of the visible notification in the notification center is a user decision, the user in Settings can decide to set a different number or decide to do not show them in notification center as well. As for the first point no. The third point is not clear, you can set the image you want for a remote just put in the payload the right name, local notifications use the app icon.
There is no silent notification for Local Notification. The user has to click to the notification to open your App.
I suppose that the associated application has deleted those notifications programmatically. Else, those notifications must stay in the notification center.
You cannot add image to action buttons but just the titles.
I tried more than two weeks to do the same. I had to show notification after 2 hrs even if the use doesn't click the notification. But the repetition facility is well handled in objective C. I could have created multiple local notification but it will also violates the total number of 64 notifications. Apple needs to improved the same.
I use a phone gap plugin and xcode 5.
Lets see the example of the problem:
The application is in background or closed.
I send the notification.
User sees the notification pop up, without clicking on it.
I send another notification.
If user open notification bar it will see two notification actually i want
to delete the previous some how and present to user only the second notification.
The eqvivalent in java is NotificationManage.cancelAll();
For now each/all notification i send are shown when user open notifications bar.
Any help appreciated.
You have (the app has) no control over that.
The user controls how many notifications they see in notification center. Notifications can be removed by the user and will be removed when acted upon (the app is opened from the notification).
You can do this by [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
in the method didReceiveRemoteNotification. In this way notification center will be cleared.
My app is queuing local notifications (and can also receive APNs) and the app's icon badge is getting set as a consequence.
When the app launches I want to clear the icon badge but I want the notifications to remain in the notification center history lists. But it seems this isn't possible? Setting the badge count to 0 has the effect of removing all notifications from the notification center.
Is there any way I can leave them there so it is the user's responsibility to remove them, yet at the same time clear the app's badge?
No, unless something has recently changed, the notifications in Notification Center are tied to the applications icon badge.
This code reads like it should clear only the badge, however, it is commonly used to clear the notifications in Notification Center:
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
However, when the code is used, the Notification Center notifications are cleared as well. Notification Center reads what to display based on what is displayed on the icon.
Sources:
My own experience
This previous question