Detect if application: didReceiveRemoteNotification: fetchCompletionHandler: was called by tapping on a notification in Notification Center

前端 未结 8 1873
北荒
北荒 2021-01-30 16:38
application: didReceiveRemoteNotification: fetchCompletionHandler:

is different from

application: didReceiveRemoteNotification:
         


        
8条回答
  •  青春惊慌失措
    2021-01-30 17:32

    In case of swift

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
    
        let state : UIApplicationState = application.applicationState
        if (state == .Inactive || state == .Background) {
            // go to screen relevant to Notification content
        } else {
            // App is in UIApplicationStateActive (running in foreground)
        }
    }
    

提交回复
热议问题