Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
I have a question about the background modes in iOS.
I want to run an timer, that checks an xml file for receiving local notifications every ... 5 minutes.

is this possible? And for how long will it run?

I'm throwing this into applicationDidFinishLaunching

Code:
UIBackgroundTaskIdentifier bgTask;
    UIApplication  *app = [UIApplication sharedApplication];
    bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:bgTask];
    }];
    self.notificationTimer = [NSTimer scheduledTimerWithTimeInterval:300 target:self
                                                       selector:@selector(checkNotifications) userInfo:nil repeats:YES];

The first time it will run for an ... ~ 5 minutes then the timer stops. After I reopen the app, it starts running again but when going back to background it won't anymore..
 
Last edited:
Well... to be honest I'm not sure how the push notifications through the server works. And for Android there is a limit of 200 or 2000.
And I'm not sure if you can send these pushes to a certain user?
I only want to send the notification to the users that have the object in their 'watchlist'.

I gather all information I need for the app from my webserver, which generates xml files to reduce the use of the SQL server.
Therefor I want to use local push notifications as well.

Every 'object' will have its own xml files,also one wich contains notification messages. Like event's and stuff.

But... I want to keep update the notifications while the app is in background (not closed).

I have no idea how to do this properly like.. whatsapp does ?? Whatsapp even works when the app is closed and is not being affected by the amount of time its in the background!?
 
Ok, time to adjust my question.
I just read about the APNs from Apple. However I can't find any guidelines about this. Like.. max amount of messages to be send in a day/week/month.

Next to that, how do I prepare my application like so that when the user presses the home button, that the messages will still be received even when the user already had the application in the background for like.. 30 minutes?

However if someone has some advice for me about push notifications, I'd like to hear.

For now I'm using local push notifications. But still unclear about the background modes.

Ofcourse when the app is opened I can read out the xml for any notifications, and plan them on desired time. Even when the user loses internet or closes the app the notification will be shown.

However, is it possible to make my app keep getting the information from the xml on the net like... every 10 minutes, when it's in background?
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.