I have a requirement to make an web-service call up on tapping actionable buttons from the Remote notification.
On the Remote notification, we have two buttons "Details" and "Fetch". "Fetch" is a background action (Activation Mode = UIUserNotificationActivationModeBackground) and will send some data with out launching the app.
On tapping "Fetch", i made a web-service call to send some details which i got from remote notification.
I have used NSURLSession to send those data to server.
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"com.applewatch.sample"];
self.session = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:self delegateQueue:nil];
NSURLSessionUploadTask *dataTask = [self.session uploadTaskWithRequest:mutableURLRequest fromData:nil];
[dataTask resume];
This works fine when the app is in active state but not in the suspended mode. What i meant to say here is, Once we get the Remote notification and if act after 1 hour on the notification, the service request is not going through.
I suspect, the service request is not going through because the app is in suspended mode/termination mode.
Could some help me how to make service calls in the background.
Note: I have not enabled "Background Fetch" options in info.plist.
Let me know if need to enable and implement the service calls in the UIApplication delegate
application:performFetchWithCompletionHandler: