Reputation: 171
I am developing iphone application where i want to develop feature of taking backup of files inside the application on to the server for every hour even if the application is completely closed.
I have tried to use NSLocalNotification
but it is not calling method
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
in appdelegate. The notifier showing alert box with the buttons cancel and view , If I click in view it opens the application but not calling the method. Even if user say cancel then also it should call this method.
So it is not calling web service to take backup of files. Can any one please direct me to link which does the same.
Thanking You, Rohit Jankar
Upvotes: 1
Views: 760
Reputation: 125017
I am developing iphone application where i want to develop feature of taking backup of files inside the application on to the server for every hour even if the application is completely closed.
If you're talking about backing up files to your own server every few hours, there's really no way to do that. On the other hand, there should also be no need to do it when the app isn't running -- if the app isn't running, it can't modify data in its files and there shouldn't be any need to back up. Instead, just make sure that you back up your data periodically when the app is running.
If you just want to make sure that the app's data is backed up somewhere, consider using iCloud. Once you've set up your app to use iCloud, your data will be backed up whenever you update it.
Upvotes: 1
Reputation: 69499
You really can't do what you want. Since iOS does not allow application to run in the background unless it's is a VOIP
client, AudioPlayer or track the user location.
The problem with the solution with UILocalNotification
is that iOS handles the notification. When the user clicks cancel your app does not get informed about this. You can only handle the view button clicks.
The-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
is only called if you app is run or is restored from background running.
If you app gets start by the system when you user click view on the Local notification you will need to check if there is a notification in the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
method:
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification) {
//handle the notification.
}
Upvotes: 2