Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 !

like image 931
rdurand Avatar asked Apr 18 '26 09:04

rdurand


1 Answers

You should use an NSNumber. I.e.

[push setData:@{
    @"alert": @"Here is the content of the notification !",
    @"badge": @1,
    @"sound": @"cheering.caf"}];
like image 56
Thomas Bouldin Avatar answered Apr 20 '26 02:04

Thomas Bouldin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!