Dock或控制中心不会使应用程序处于非活动状态

时间:2017-09-07 10:13:53

标签: ios swift push-notification ios11 uiapplication

当我打开导航抽屉应用程序时.ApplicationState应该是Inactive,但在iOS 11中它是Active。

我想通过点击Notification Center中的通知来检测是否已调用application:didReceiveRemoteNotification

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)
    }
}

它是iOS 11中的错误还是推送通知的新方法?

检查applicationState的其他方法:

func applicationWillResignActive(_ application: UIApplication) {
    var app = application.applicationState
}

0 个答案:

没有答案