ios 10 , ,
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
, ,
AppDelegate :
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var isUserTapOnNotification = false
true isUserTapOnNotification
func applicationWillEnterForeground(_ application: UIApplication) {
isUserTapOnNotification = tue
}
, , applicationWillEnterForeground ,
didReceiveRemoteNotification :
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if
//do nothing
}else { //<ios 10
if isUserTapOnNotification == true {//when app is in background and user tap on notification bar
//do action whatever you want
} else { //when user is in foreground and notification came,
//before ios10,notification bar not display in foreground mode,So you can show popup by using userInfo
}
}
applicationDidBecomeActive , reset isUserTapOnNotification - false :
func applicationDidBecomeActive(_ application: UIApplication) {
isUserTapOnNotification = false
}
, .