update
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user