6

I'm using the following code to schedule a UILocalNotification in my app. The problem is that the notification animates twice.

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

That code is executed in a button action. Then I send the app to the background and wait for the notification to be fired.

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

First I was starting to think that it was an iOS bug, but then I created a very simple project with only the code that fires the notification and the problem did not happen.

When the app enters this state the problem occurs always. If I restart the device then everything starts working as expected. I did not manage to find the pattern that puts the app in this state.

This only happens on iOS 9 devices.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nuno Vinhas
  • 528
  • 4
  • 12

1 Answers1

5

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

This post helped.

Community
  • 1
  • 1
fcardoso
  • 76
  • 2