1

Imagine this: A user sees a notification on their lock screen e.g. "your server is online". Then something changes e.g. the server goes offline. Can I programmatically remove that notification (dismiss it) from the background even after it has been displayed on the lock screen?

JDeau
  • 13
  • 3

1 Answers1

3

Yes you actually can do this, you typically see it in action in messenger apps or social networking apps, for example, in some messenger app that has a web version, if you receive a message and you read it from the web but you already have received the push on your iOS app, when this happens you must send another push without display message, but a tag with value that indicates whatever you want:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

  if([[userInfo objectForKey:@"reset"] boolValue]){
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
  }

}

This is a silent push notification.

Karlo A. López
  • 2,548
  • 3
  • 29
  • 56