ios icon indicating copy to clipboard operation
ios copied to clipboard

How can I prevent to receive notification when app in foreground?

Open AlanWen2016 opened this issue 4 years ago • 2 comments

PM doesn' t want to get notification when app in foreground.How can I prevent to receive notification when app in foreground?

AlanWen2016 avatar Oct 26 '21 06:10 AlanWen2016

@AlanWen2016 send local notification, when the remote came

Wimmind avatar Nov 08 '21 09:11 Wimmind

you can change the behavior in your app delegate:

// Called when a notification is delivered to a foreground app.
  -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
  {
    completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
  }

https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter?language=objc

sounds like you'll want UNNotificationPresentationOptionNone ( other options documented here)

tavour-frank avatar Jan 28 '22 00:01 tavour-frank