2

I am having troubles increasing the badge number using the Parse iOS Framework.

When I call this code, the other user gets the Push notification, but his badge number is not increasing on the icon.

    let push = PFPush()
    let data = ["badge": "Increment"]
    push.setData(data)
    push.setChannel("channel_\(userId)")
    push.setMessage(message)
    var err: NSError?
    do {
        try push.sendPush()
    } catch var error as NSError {
        err = error
    } catch {
        fatalError()
    }

Thanks!

Russell
  • 3,099
  • 2
  • 14
  • 18
AustinT
  • 1,998
  • 8
  • 40
  • 63

2 Answers2

1

Try with this in swift for increase

    let currentCountStr = UIApplication.sharedApplication().applicationIconBadgeNumber.description
    let currentCount = Int(currentCountStr)
    if(currentCount > 0) {
        UIApplication.sharedApplication().applicationIconBadgeNumber = currentCount! + 1
    } else {
        UIApplication.sharedApplication().applicationIconBadgeNumber = 1
    }
Dey
  • 842
  • 9
  • 21
0

You should check your database and/or code if you successfully updated 'Installation' table. The way it works is, that they store badge number in that table (perhaps refresh after each application is awaken) so later server can send incremented number inside notification payload.

Parse had a blog entry on this : http://blog.parse.com/announcements/badge-management-for-ios/

Just to add note how it works in more generic environment : You should send actual new badge number from the server, it is not just incremented for you.

There is good deal of information on another question : Increment the Push notification Badge iPhone

Community
  • 1
  • 1
PetrV
  • 1,368
  • 2
  • 15
  • 30