I'm building a native iOS app which is using Salesforce SDK. I'm getting my data using SFRestApi like below.
SFRestRequest *req = [[SFRestRequest alloc] init];
[req setDelegate:self];
[req setEndpoint:@"/services/apexrest"];
[req setMethod:obj.localOption];
[req setPath:obj.localpath];
[req setQueryParams:obj.dicParam];
[req setParseResponse:YES];
[[SFRestAPI sharedInstance] send:req delegate:self];
and here is my SFRestRequest Delegate Methods
- (void)request:(SFRestRequest *)request didLoadResponse:(id)dataResponse;
- (void)request:(SFRestRequest *)request didFailLoadWithError:(NSError *)error;
- (void)requestDidCancelLoad:(SFRestRequest *)request;
- (void)requestDidTimeout:(SFRestRequest *)request;
These methods are working perfectly. But I'm planning to add new feature "Background Fetch" in my app so I added these lines below in my AppDelegate class.
#pragma mark - AppDelegate Background Fetch
-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSLog(@"Fetch started");
[self.Syncer syncWithOption:SYNC_METHOD_GETSEND]; //This is where I start sync
completionHandler(UIBackgroundFetchResultNewData);
NSLog(@"Fetch completed");
}
-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:30];
return true;
}
Problem is that those 4 SFRestRequest Delegate Methods are not firing when I start background fetching. When I reopen the app, It fires one of those Delegate Methods and continues where it left. Is this an issue about the SDK or should I implement something to make it right ?