我想在收到本地通知时,自动查看控制器/(Ios App)打开而不点击通知,是否可能..?
func applicationDidEnterBackground(_ application: UIApplication) {
print("EnterBackground.")
//Crete a local notification
let notification = UILocalNotification()
notification.alertBody = "This is a fake notification"
notification.fireDate = NSDate(timeIntervalSinceNow: 2) as Date
UIApplication.shared.scheduleLocalNotification(notification)
let mainStoryboardIpad : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewControlleripad : UIViewController = mainStoryboardIpad.instantiateViewController(withIdentifier: "ScreenLockedViewController") as UIViewController
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = initialViewControlleripad
self.window?.makeKeyAndVisible()
// NotificationCenter.default.post(name: NSNotification.Name(rawValue: "launchSecondView"), object: nil)
// if let viewController = window?.rootViewController as? ViewController {
// viewController.viewDidLoad()
// }
}