【发布时间】:2021-04-27 19:49:42
【问题描述】:
我想将来自Firebase 的push notifications 接收到我的SwiftUI 的应用程序中。
我可以看到我的通知并且效果很好,但我不知道如何处理操作值来处理数据。我读到了didReceiveRemoteNotification,但没有用。你知道我做错了什么吗?
非常感谢...
AppDelegate.swift
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
print(userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
print(userInfo)
completionHandler(UIBackgroundFetchResult.newData)
}
【问题讨论】:
标签: firebase push-notification swiftui apple-push-notifications