【发布时间】:2018-09-08 12:05:46
【问题描述】:
如果我收到通知,则不会显示徽章。
这是我注册通知的地方(如您所见,已选择徽章):
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
if error == nil {
if granted {
print("granted")
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
UNUserNotificationCenter.current().delegate = self
}
} else {
print("not granted")
}
}
}
} else {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [UIUserNotificationType.badge, UIUserNotificationType.sound, UIUserNotificationType.alert], categories: nil)
UIApplication.shared.registerForRemoteNotifications()
UIApplication.shared.registerUserNotificationSettings(settings)
}
这是我的有效载荷:
notificationJsonPayload =
"{\"aps\" : " +
" {" +
" \"alert\": \"$(Message)\"," +
" \"badge\": 1" +
" }" +
"}";
通知显示在顶部,但应用图标上没有任何徽章。
【问题讨论】:
-
在对象中尝试json有效负载aps对象与此jsonblob.com/920108b6-3358-11e8-80b3-2fe0f921f022
-
这和我的格式一样,只是它也有声音......
-
什么是后端语言? PHP ??
-
语言是C#
-
确保在通知中启用了该应用并确保允许使用徽章应用图标
标签: ios iphone swift push-notification apple-push-notifications