ios - Background fetch stops working after about 10 to 14 hours -
my application uses backgroud fetch send , upload small portion of data every 30 minutes. service working correctly 10 - 14 hours after application minimized working in foregroud - application correctly sending , receiving data every 30 minutes.
does know happens service after couple of hours? ios system automatically terminate application , therefore background fetch stops working?
can explain?
ios provides 30 seconds time frame in order app woken up, fetch new data, update interface , go sleep again. duty make sure performed tasks manage finished within these 30 seconds, otherwise system stop them.
maybe internet slow app took more 30 seconds & system stopped application.
-(void)application:(uiapplication *)application performfetchwithcompletionhandler:(void (^)(uibackgroundfetchresult))completionhandler{ nsdate *fetchstart = [nsdate date]; // make process here [viewcontroller fetchnewdatawithcompletionhandler:^(uibackgroundfetchresult result) { completionhandler(result); nsdate *fetchend = [nsdate date]; nstimeinterval timeelapsed = [fetchend timeintervalsincedate:fetchstart]; nslog(@"background fetch duration: %f seconds", timeelapsed); }]; }
also apple provides algorithm defines how background fetch should trigger, based on own usage of app. if use lot, fetch possible, if use @ 4pm every day, background fetch should trigger before, data updated when launch it.
Comments
Post a Comment