Question

Trigger.io provides a forge.notification.setBadgeNumber method to set the ios badge number. Is it possible to retrieve the badge number with trigger.io?

My use case is that I have a messaging system where the badge number is the number of unread message - I want to decrease the badge number when the user reads a message. To do that, I need to know the current badge number...

Suggestion on better ways to implement this will also be appreciated.

Était-ce utile?

La solution

You could easily write your own native module to get the current badge count in Trigger.io apps. I have one in use and the relevant function looks like this:

+ (void)getBadgeNumber:(ForgeTask*)task {
  NSNumber *count = [NSNumber numberWithInt:[[UIApplication sharedApplication] applicationIconBadgeNumber]];
  [task success:count];
}

UPDATE:

It seems like Trigger.io added the getBadgeNumber call to their notifications module. Available methods are:

  • forge.notification.setBadgeNumber(number, success, error)
  • forge.notification.getBadgeNumber(success, error)

If you're using the Parse module for push notifications you can even retrieve and set the badge number on the Parse server as of now.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top