检测用户何时在应用程序处于前台时点击通知
Detect when user taps on a notification while app is in foreground
userNotificationCenter(...,didReceive,...)
和userNotificationCenter(...,willPresent,...)
分别用于:
当应用程序处于后台
时用户点击通知时的处理
当 phone 收到 通知而应用程序处于 前台 时处理。
但是当应用程序处于前台时,我们如何处理用户点击通知的事件? (例如,在点击通知时将用户带到相关的视图控制器)
有两种 didReceive 方法,它们的作用不同。
正如它在 the page for the didReceiveRemoteNotification:fetchCompletionHandler 上所说:
"Unlike the application(_:didReceiveRemoteNotification:) method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background."
userNotificationCenter(...,didReceive,...)
和userNotificationCenter(...,willPresent,...)
分别用于:
当应用程序处于后台
时用户点击通知时的处理当 phone 收到 通知而应用程序处于 前台 时处理。
但是当应用程序处于前台时,我们如何处理用户点击通知的事件? (例如,在点击通知时将用户带到相关的视图控制器)
有两种 didReceive 方法,它们的作用不同。 正如它在 the page for the didReceiveRemoteNotification:fetchCompletionHandler 上所说:
"Unlike the application(_:didReceiveRemoteNotification:) method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background."