This commit is contained in:
DDIsFriend
2023-08-30 18:35:34 +08:00
parent 456b879a00
commit cce7060345
11 changed files with 163 additions and 5 deletions

View File

@@ -13,10 +13,31 @@ open class GroupData {
public static let `default` = GroupData()
let groudUserDefault = UserDefaults(suiteName: GROUPID)
//
func parserAlertToDictionary(userInfo:[AnyHashable:Any]?) -> Dictionary<String,String>? {
let aps = userInfo?[pushNoti_aps_key] as? [String:Any]
if let data = (aps?[pushNoti_alert_key] as? String)?.data(using: .utf8) {
let dict = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: String]
return dict
}
return nil
}
func parserAlertToString(userInfo:[AnyHashable:Any]?) -> String? {
let aps = userInfo?[pushNoti_aps_key] as? [String:Any]
let string = aps?[pushNoti_alert_key] as? String
return string
}
//
func isOrderPushNotification(userInfo:[AnyHashable:Any]?) -> Bool {
if let userInfo {
if let aps = userInfo[pushNoti_aps_key] as? [String:Any], let dict = (aps[pushNoti_alert_key] as? Dictionary<String, Any>), (dict[pushNoti_title_key] as? String) == pushNoti_newOrder_key {
if let dict = parserAlertToDictionary(userInfo: userInfo), dict[pushNoti_title_key] == pushNoti_newOrder_key {
return true
}
if let string = parserAlertToString(userInfo: userInfo), string.contains(pushNoti_newOrder_key) == true {
return true
}
}