I was able to fix this with some great checks ...
Essentially, the key to this goal is
-(void)applicationDidEnterBackground:(UIApplication *)application;
This method is not called when entering a quick application switch (or control center), so you need to configure a check based on this.
@property BOOL isInBackground; @property (nonatomic, retain) NSMutableArray *queuedNotifications;
And when you receive a notification ...
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { UIApplicationState appState = application.applicationState;
And then when we get back ...
- (void)applicationDidBecomeActive:(UIApplication *)application { application.applicationIconBadgeNumber = 0; if (!self.isInBackground) {
Another thing you might want to do is check out this special case of switching to quickly switching applications and the user going somewhere else. I do this before installing isInBackground BOOL. I prefer to send them as local notifications
-(void)applicationDidEnterBackground:(UIApplication *)application { for (NSDictionary *eachNotification in self.queuedNotifications) { UILocalNotification *notification = [self convertUserInfoToLocalNotification:eachNotification]; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; } self.queuedNotifications = [NSMutableArray array]; self.isInBackground = YES; }
source share