With following code I get (2) in the badge icon immediately after app compiling:
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let installation = PFInstallation.currentInstallation()
installation.setDeviceTokenFromData(deviceToken)
installation.badge = 2
installation.saveInBackground()
}
I did try the next variant: Initialized a new var badgeCount = 0
and later:
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
badgeCount++
let installation = PFInstallation.currentInstallation()
installation.setDeviceTokenFromData(deviceToken)
installation.badge = badgeCount
installation.saveInBackground()
}
But when I get new notifications it doesn't update to +1. Is anyone know how to fix it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…