UILocalNotification animates twice

I use the following code to schedule a UILocalNotification in my application. The problem is that the notification comes to life twice.

 UILocalNotification *localNotification = [UILocalNotification new]; localNotification.alertBody = @"Test message"; localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:3]; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 

This code is executed in a button action. Then I send the application to the background and wait for the notification to start.

What happens is that I only have one notification, but the animation (slide animation) is done twice.

At first I started to think that this is an iOS error, but then I created a very simple project with only code that triggers a notification, and the problem did not occur.

When an application enters this state, a problem always arises. If I restart the device, everything will start working as expected. I could not find a template that puts the application in this state.

This only happens on iOS 9 devices.

+5
source share
1 answer

I had the exact same problem a while ago and was caused by several calls to registerUserNotificationSettings when initializing notifications (in this case, didFinishLaunchingWithOptions ).

This post has helped .

+5
source

Source: https://habr.com/ru/post/1243063/


All Articles