func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
/*
let aps = userInfo["aps"] as! [String: AnyObject]
if let count = aps["badge"] as? Int {
application.applicationIconBadgeNumber = 2
}
*/
let custom = notification["custom"] as! [String: AnyObject]
if let home = custom["a"]!["home"] as? String, home == "1" {
incrementBadgeNumberBy(badgeNumberIncrement: 1)
}
}
答案 0 :(得分:2)
在通用应用程序徽章中,是从推送通知有效负载中设置的。
有效负载示例:
{
“aps” : {
“badge” : 9
},
}
或
您还可以使用设置徽章
UIApplication.shared.applicationIconBadgeNumber = 3