解密通知数据并在iOS -Flutter应用中使用数据
我正在Flutter应用程序中实施通知并检查iOS。方案是当用户在iOS中收到通知时,我想加密该数据以用于进一步的功能实现。这是我在appdelegate
文件中
override func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
self.flutterMethodChannelLocalNotification.invokeMethod("localnotification", arguments: userInfo["data"] ?? "")// output: "some-value"
let data = userInfo["data"] as? [String:Any]
let param : [String:Any] = [KeyCenter.kUserId: data?[KeyCenter.kNotificationForUserId] ?? "" ,
KeyCenter.kGroupId: data?[KeyCenter.kGroupId] ?? "",
KeyCenter.kChatType: data?[KeyCenter.kChatType] ?? ""]
print("Param data = \(param)")
viewModel = ViewModel()
viewModel.doubleTickCallApi(params: param, completion:{ (sucsses, message) in
if sucsses{
}else{
print(message ?? "Unexpected")
}
completionHandler(.newData)
})
// Inform the system after the background operation is completed.
}
写入param
时写的功能,它将是param data = [“ userId”:“”,“”,“ chattype”:“ “,” groupId“:”]
。如何处理可选的userInfo [“ data”]
在这里值?
I am implementing notification in flutter app and checking for iOS. Scenario is when user receive notification in iOS I want to encrypt that data to use for further feature implementation. Here is my function which I write in AppDelegate
file
override func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
self.flutterMethodChannelLocalNotification.invokeMethod("localnotification", arguments: userInfo["data"] ?? "")// output: "some-value"
let data = userInfo["data"] as? [String:Any]
let param : [String:Any] = [KeyCenter.kUserId: data?[KeyCenter.kNotificationForUserId] ?? "" ,
KeyCenter.kGroupId: data?[KeyCenter.kGroupId] ?? "",
KeyCenter.kChatType: data?[KeyCenter.kChatType] ?? ""]
print("Param data = \(param)")
viewModel = ViewModel()
viewModel.doubleTickCallApi(params: param, completion:{ (sucsses, message) in
if sucsses{
}else{
print(message ?? "Unexpected")
}
completionHandler(.newData)
})
// Inform the system after the background operation is completed.
}
when I print param
it will be Param data = ["userId": "", "chatType": "", "groupId": ""]
. How to handle optional userInfo["data"]
value here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是我必须在JSON中解析通知数据,然后使用它
Solution is I have to parse notification data in json and then use it