我有一个 ios 应用程序,我在从服务器发送通知时向其中发送远程通知我正在设置内容 -available = 1和声音 =“” 当我在 IOS 设备上使用时
应用程序(didReceiveRemoteNotification:fetchCompletionHandler :)
我看到该应用程序在后台时到达此方法,但是当应用程序关闭时,此方法没有被调用但是在应用程序关闭时没有被调用
应用程序(didReceiveRemoteNotification:fetchCompletionHandler :)
我在这个方法中的处理程序是
let userInfoDic = userInfo as NSDictionary as? [String: Any]
let cato = userInfoDic?["cato"] as? String
if cato == "message" {
let state: UIApplicationState = UIApplication.shared.applicationState
if state == .active{
print("Application is Active Socket IO will Handle This")
}else{
let apnMessage = userInfoDic?["apnMessage"] as? [String: Any]
if (apnMessage == nil){
print("Error Fetching Message")
}else{
let count = UserDefaults.standard.integer(forKey:"TotalUnredMessage")
DispatchQueue.main.async {
UIApplication.shared.applicationIconBadgeNumber = count + 1
}
UserDefaults.standard.set(count, forKey: "TotalUnredMessage")
}
}
那么即使应用程序关闭,我应该改变什么才能运行此方法
谢谢