Incrementing the badge in an iOS app

I have looked through the Backendless support pages and there seems to be a number of different tickets regarding this issue: here, here, here etc.
The general answer seems to be to add your badge number to the push payload in the format:

@"badge" : @N,

In some answer this link has been referred to for incrementing: https://backendless.com/documentation/utilities/ios/ut_atomic_counters_ios.htm
All of these answers seem to be pointing towards knowing the notification value when you send the push.
We are using Backendless for our chat component meaning that when you send a user a message it should increase their current notification number by 1. This means we can’t send a value as the calculation will take place depending on their device.
I have looked at using the atomic counter increment but the article isn’t particularly clear.

id <IAtomic> myCounter = [backendless.counters of:bBadge];
NSNumber *result = [myCounter incrementAndGet];

If I calculate the number before I send the push then it will not calculate the other user’s notification value.
Currently the function

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

isn’t being called when we receive a notification meaning that I can’t use this to set the badge number.
Is there a way to effectively increment the other users badge number through push notifications? Is it integrated into the test project or anywhere that I can use to get it working in our project?
Any help on this would be very appreciated,
Simon

The application delegates

 func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
 backendless.messaging.didReceiveRemoteNotification(userInfo)
 }
 
 func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
 backendless.messaging.didReceiveRemoteNotification(userInfo)
 completionHandler(.NewData)
 }

call the IBEPushReceiver method:

 func didReceiveRemoteNotification(notification: String!, headers: [NSObject : AnyObject]!) {
 print("RECEIVED: \(headers["publisher_name"]) -> \(notification)")
 }

so you could increment the badge number using it.

Hi

I have tried adding this but the first hurdle I reach is that in iOS the didReceiveRemoteNotification function isn’t being called in the background.

After trying to find the answer there seem to be lots of answers saying it can’t be done without a server backend:

Both of these (and the majority of others found) seem to be saying that we can’t call code and update the badge in didReceiveRemoteNotification for iOS and update the badge.

When looking for the IBEPushReceiver I can only find a reference to it in the MessagingService.h file. Where should I add the increment code that you specified above?

Simon

The internal task BKNDLSS-13429 is created. We need some time to implement it (in 4.0 version)

Do you have any idea of when this will be released?

Thanks

Simon

Hi Simon,

A preview of the 4.0 version will be released this month.

Regards,
Mark