有人可以向我展示如何使用高级选项从Firebase控制台面板捕获通知的示例,您可以在其中发布文本,值和密钥。我怎么能在代码中捕获这个?
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
}
此方法负责捕获。 UserInfo是一个包含所有内容的字典。我想从这个信息中获取关键值。
提前致谢!
答案:
每当你想通过你自己的键和值得到smth时,它就像这样:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let info = userInfo as NSDictionary
let name = info.value(forKey: "Name")
let lastName = info.value(forKey: "LastName")
let age = info.value(forKey: "Age")
}