rdurand
rdurand

Reputation: 7410

Parse.com push notification badge value

I use parse.com and the iOS Parse Framework in an iOS app. I want to send a push notification to a channel, but I would like the value of the badge to be set to 1, even if the user receives multiple notifications.

Here is the code used to send the notification, taken from the documentation :

NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
    @"Here is the content of the notification !", @"alert",
    @"Increment", @"badge",
    @"cheering.caf", @"sound",
    nil];
PFPush *push = [[PFPush alloc] init];
[push setChannels:[NSArray arrayWithObjects:@"A Channel", nil]];
[push setData:data];
[push sendPushInBackground];

Here is what they say (go to "Sending options" > "Customizing your notifications") about the value of the badge key in the dictionary :

badge: (iOS only) the value indicated in the top right corner of the app icon. This can be set to a value or to Increment in order to increment the current value by 1.

So obviously, the value @"Increment" works fine, but I want to always set the badge value to "1".

What is the correct syntax ? I can't seem to find it !

Upvotes: 3

Views: 3878

Answers (1)

Thomas Bouldin
Thomas Bouldin

Reputation: 3725

You should use an NSNumber. I.e.

[push setData:@{
    @"alert": @"Here is the content of the notification !",
    @"badge": @1,
    @"sound": @"cheering.caf"}];

Upvotes: 4

Related Questions