Reputation: 1100
I am using Parse as my backend for my iOS app to send push notifications. My problem is that the app icon never shows a badge after receiving push notifications (Besides for the badge, everything works fine).
I've checked the "badge" field in the Installation DB on Parse and it is increasing with every push, so I feel it might be a client-side issue
Here is my cloud code:
Parse.Push.send({
where: pushQuery,
data: {
aps: {
alert: "Your friend " + request.user.get("Name") + " just joined VoiceMe!",
sound: "default",
AlertType: "NewFriend"
},
badge: "Increment"
}
}, {
success: function() {
/*all is good*/
},
error: function(error) {
outcome = false;
errorOutput = error;
}
});
And the code in my app:
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let currentInstallation = PFInstallation.currentInstallation()
if PFUser.currentUser() != nil {
currentInstallation.setObject(PFUser.currentUser()!, forKey: kParseInstallationUserKey)
}
currentInstallation.setDeviceTokenFromData(deviceToken)
currentInstallation.channels = ["global"]
currentInstallation.saveInBackgroundWithBlock { (resultBool, error) -> Void in
println("register device: --- \(resultBool) ---- error: \(error)")
}
}
Image of Installation DB on Parse:
Upvotes: 1
Views: 958
Reputation: 10602
See my answer here: https://stackoverflow.com/a/27615528/2353523 for reference
you've created your own dictionary. That's used for interactive notifications etc. Badge is outside of that dictionary that you've created which is the correct dictionary for sending pushes. That's why it doesn't increment in the payload you created under the dictionary of aps. You have to tell it to. Else, just delete the aps dict and pass your parameters through the data dict
Upvotes: 3