我想知道当终止的应用程序从我的服务器收到通知时会触发哪种方法。该应用程序是通过Swift 4开发的,我的部署目标是10.3,Firebase用于向用户发送通知。
我在AppDelegate.swift中配置了我的应用程序:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
Messaging.messaging().delegate = self
UNUserNotificationCenter.current().delegate = self
}
此外,我创建了扩展程序:
@available(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
}
}
当应用收到通知并且正在运行或处于后台运行时,方法" willPresent"被调用,当用户点击通知并决定打开它时,方法" didReceive"叫做。如果应用程序终止,则不会触发任何方法。
我做错了吗?