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.
Asked
Active
Viewed 1,610 times
0
-
Hit `API for Deleting FCM token when app is in background` instead. – Amir Khan Mar 29 '19 at 05:43
-
@AmirKhan then will i get Push notifications when app is Background?. since i have delete FCM Token from API – Jay Patel Mar 29 '19 at 05:45
-
No, then App only gets notification when App is in foreground. – Amir Khan Mar 29 '19 at 05:46
-
Oh sorry my bad. I got it wrong. You can implement socket connectivity where server will check whether user is still connected or not. – Amir Khan Mar 29 '19 at 05:48
-
@AmirKhan requires Push notifications till user doesn't manually Killed App from device – Jay Patel Mar 29 '19 at 05:48
-
1If app is currently running in the `background and not suspended`, the system calls the `applicationWillTerminate: of its app delegate prior to termination. Other than `applicationWillTerminate` will not called. Check here - https://stackoverflow.com/questions/29416375/when-will-applicationwillterminate-be-called – Amir Khan Mar 29 '19 at 05:54
-
https://github.com/vishalkalola1/PushNotification you can follow the step and when app is terminate you get notification into didfinishlaunch method. – Vishal Patel Mar 29 '19 at 06:01
1 Answers
0
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) {
}

Sourabh Kumbhar
- 1,034
- 14
- 12