Reputation: 51
I implemented the performFetchWithCompletionHandler for background fetch. I have local notifications setup to fire when there is change in data. For test purposes I also had notifications to fire even when there is no change in data so that I know things are actually working, and I don't have to wait for remote data to change to test my app).
With the app in debug mode in xcode, I use the "Simulate Background fetch" option, and background fetch works as expected. Notifications are displayed on the simulator as expected.
Deleted the old app on the phone. I connect the ip5 device to xcode and run the app. App is updated on iphone. When in debug mode, I execute the "Simulate Background fetch" option. I see local notifications as I expected.
now I have disconnected the device and I have been opening and closing the app every hour (amlost!), but background fetch has not fired even once, and I have not seen any local notification yet.
I have set the code to do this:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
return YES;
}
What am I doing wrong?
Upvotes: 1
Views: 1315
Reputation: 513
In Xcode 5 Debug mode, you can force a background fetch from the menu: Debug > Simulate Background Fetch.
Please check this link performFetchWithCompletionHandler never gets fired
Upvotes: 1
Reputation: 628
Hoping that this is not the case:
What type of background fetch are you doing? It is possible that the fetch may work once in the debugger and not again - and then when you run an actual IPA, because you are, for example, doing a dataTaskWithRequest or something similar - that it won't work.
Upvotes: 0