UILocalNotification multiple firing - iphone

I schedule a UILocalNotification at at specific date, and the notification is fired correctly, But the problem is that I receive multiple alerts at random dates for same notification even though the notification is not repeated (repeatInterval = 0 ).
Another note, when I receive the notification at first time , it appears correctly in notification center, but later when I receive the multiple alerts nothing updated in notification center.
Please note that this event is repeated daily, but the notification not get repeated.
Any solution for this issue?

I expect you are never calling:
[[UIApplication sharedApplication] cancelAllLocalNotifications]
These notifications appear to be "old" notifications that haven't been cancelled and are still due to fire. Did you ever have a repeat interval? Some of these notifications could be repeated from very old notifications

Related

iOS: Notification Badge Number does not reset

I want to reset the notification badge number whenever the app is opened. This works perfectly fine calling
application.applicationIconBadgeNumber = 0
UNUserNotificationCenter.current().removeAllDeliveredNotifications()
However, when I one ore more new notifications come in, the icon badge number again goes to 42 no matter how many notifications come in.
Does anyone know how to fix this?
You can follow one of the following for achieving this,
You can store notifications received in your database and when user opens app, you can get the count of unread notifications and update the count.
If you are targeting single users then, you can get the delivery of Push notifications using https://stackoverflow.com/a/50044201/5084797 and then when the notification is opened you can pass notification Open event to server. So the next time the server sends push notification, they can just check for the difference in Deliver and Open and send that count in badge. If user has cleared all notifications from Notification centre without opening them. In that case as soon as App opens you need to update that at server, Else you might be getting wrong count from server.

UILocalNotification shows 400 badges

I am scheduling a UILocalNotification for an interval. Basically I wanted a notification to be triggered every x days on this app. So the way I did it is to schedule a bunch of notifications at once. So say it's every 2 days, then I do a calculation of the dates every 2 days from now for a year. I am not sure if this is the right and most efficient solution to it, but from researching online, this is what I get I need to do.
The issue is that when the notification fires and I open the app, the badges count goes up to 500, which I think is the number of all future notifications I've scheduled. How is this even possible> Shouldn't the badge only show the number of notifications before the timestamp?
The badge number does not show a number of notifications, but the badge value that you set as notification payload.

Multiple push notifications on 1 device - iPhone

How to handle multiple push notifications on One device e.g:
A user receives a notification saying you have 1 new message from my app. Before he checks that message another message comes in so now he has 2. Well I don't want 2 messages stacked in the notification bar, I want 1 notification saying there are 2 messages waiting. How do I implement this?
And also if on device got 5 new notification and user taps last notification then how we got the previous notification userInfo
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
Regarding your first question, you won't be able to do this. Notifications are seperate events, and NotificationCenter won't (and can't) merge them.
Push notifications aren't meant to deliver (much) information, hence, you cannot rely on reading the userInfo objects. For example, what would you do if the user just closes the notification alert and deletes it without reading it?
What you should do is only use Push notifications to tell your app that "something has happened". The app should then fetch the information from the server. I.e, if the user taps on the last notification, the app will still download all the information linked to all five notifications.

Handling multiple notifications

I am using an app that issues many local notifications at a time. My issue is if there is more than one outstanding notification, clicking on a notification will cause the other(s) notification to be ignored. So is there any way to effectively track multiple notifications? Or even more specifically, find out which notifications were not received by the app delegate?

Is it possible to schedule push notification time ? (iPhone SDK)

I want to schedule push notification after some time or say after 2 days 15 hours. So after 2 days 15 hours a notification will be sent to a device.
Is it possible ? How ??
Since a push notification originates from a server and not the phone itself you can schedule anything the provider makes available. You will have to check with your notification service provider what they make available.
However if you just need to schedule a future alert on the phone itself, you can use the UILocalNotification class. This will just kick off a notification on the device once the timer expires.