Question

I have an app that I want to update the badge icon weekly. I see that at least pre iOS7, UILocalNotification could only set the badge icon to a specific number like

someLocalNotification.applicationIconBadgeNumber = 42;

But I want my app to load in the background lets say every sunday, do a calculation based to get the difference between the current date and some start date, and update the badge number accordingly.

UILocalNotification can't do this apparently. It looks like push notifications can, but I don't have a server component for this app, so using that as a workaround wouldn't work, and I'm not sure Apple would like it anyway.

I know there is some background app refresh updates in iOS7, but I'm not sure if they would work in this situation.

TLDR: How do I update a badge icon in iOS7 that requires a bit of calculation to get the correct number, on a weekly basis (or any arbitrarily long time basis)? And I want to do this background updating without a server component.

Was it helpful?

Solution

You simply schedule a silent local notification, with a nil message and then update the badge number. Also set the repeat count to nil otherwise the badge wont get updated if you call this local notification multiple times

This person posted a similar question, have a look

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top