Triggering a specific action when the app enters foreground from a local notification in iOS? (using swift)

后端 未结 3 2128
我在风中等你
我在风中等你 2020-12-13 18:44

I am building an iOS app using the new language Swift. Now it is an HTML5 app, that displays HTML content using the UIWebView. The app has local notifications, and what i wa

3条回答
  •  忘掉有多难
    2020-12-13 19:33

    Add Below Code in ViewController

    override func viewDidLoad() {
    super.viewDidLoad()
    let notificationCenter = NotificationCenter.default
    notificationCenter.addObserver(self, selector:#selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
       }
    
      @objc func appMovedToForeground() {
      print("App moved to foreground!")
      }
    

提交回复
热议问题