简体   繁体   中英

Handle push notification when app is in Background or Running state not when app is terminated

I am working in one of project where client requirements is like show Push notifications till app is not terminated . Push Notifications is done with Firebase Integration by sending FCM token to the Backend. I have also have one API for Deleting FCM token when app is terminated but could not execute around 30 seconds till app is Terminated .IS there anyway to check from App side when Push Notifications arrives show only when the app is running or background state.

Receive displayed notifications for minimum iOS 10 version.

     // Function call when App is in foreground State

    func userNotificationCenter(_ center: UNUserNotificationCenter,
      willPresent notification: UNNotification,  
      withCompletionHandler completionHandler: @escaping 
     (UNNotificationPresentationOptions) -> Void) { 

    }

   // Function call when App in Background State 

  func application(_ application: UIApplication, 
    didReceiveRemoteNotification userInfo: [AnyHashable : Any], 
    fetchCompletionHandler completionHandler: @escaping 
   (UIBackgroundFetchResult) -> Void) {


   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM