我不明白为什么我的代码无法正常工作。
我的代码是:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
{
print("User Info = ",userInfo)
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadChatTableView"), object: nil)
GlobalConstant.notificationDict = userInfo
let notificationDictionary: NSDictionary = GlobalConstant.notificationDict?["aps"] as! NSDictionary
let type: String = Global.getStringValue(notificationDictionary.value(forKey: "type") as AnyObject)
// application.applicationIconBadgeNumber = application.applicationIconBadgeNumber + 1
completionHandler(UIBackgroundFetchResult.noData)
var aps: [AnyHashable: Any] = userInfo["aps"] as! [AnyHashable : Any]
//content.sound = UNNotificationSound.init(named: "tone.mp3")
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil
}