ios - Background task execution is not working as expected -
i have requirement make web-service call on tapping actionable buttons remote notification.
on remote notification, have 2 buttons "details" , "fetch". "fetch" background action (activation mode = uiusernotificationactivationmodebackground) , send data out launching app.
on tapping "fetch", made web-service call send details got remote notification.
i have used nsurlsession send data 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 app in active state not in suspended mode. meant here is, once remote notification , if act after 1 hour on notification, service request not going through.
i suspect, service request not going through because app in suspended mode/termination mode.
could me how make service calls in background.
note: have not enabled "background fetch" options in info.plist.
let me know if need enable , implement service calls in uiapplication delegate
application:performfetchwithcompletionhandler:
i'm not being able recall or find again read information before, try using
- uploadtaskwithrequest:fromfile:
i believe it's upload method work in background
Comments
Post a Comment