iphone - iOS 7 Background Fetch When the App is Not Running -
i've written simple application in order test , monitor how background fetch feature works in ios7.
first of all, i've set uibackgroundmode options in info.plist file.
then;
i added below code application:didfinishlaunchingwithoptions: method in appdelegate.m:
at last, i've implemented application:(uiapplication *)application performfetchwithcompletionhandler: method requested.
every time click debug->simulate background fetch button, changes application's batch number , works expected.
however, i've never been able make work when application not running (not in background mode, not running).
apple says when application not running , os wants execute following methods respectively:
application:(uiapplication *)application didfinishlaunchingwithoptions: applicationdidenterbackground:(uiapplication *)application application:(uiapplication *)application performfetchwithcompletionhandler:
so question is there way test background fetch when app not running?
i testing on ipod 5th gen ios 7.1.
edit 2: note if user kills app app switcher, background fetch never happen again. working apple intended. see related "understanding when app gets launched background" docs details:
in cases, system not relaunch apps after force quit user. 1 exception location apps, in ios 8 , later relaunched after being force quit user.
and old developer forums post (the link unfortunately no longer exists)...
"if kill app multitasking ui, system never automatically launch app again. logic here that, if user has killed app, want stay dead."
you make simple request, eg: "http://dev.example.org/?ping=1" web server grep access.log on web server "?ping=1"
edit: method test app being launched in background (eg: without being able double tap home button , switch it) creating background-only scheme. go product -> scheme -> manage schemes , duplicate default scheme.
then edit new scheme , click options tab , check "launch due background fetch event" - when run app it'll launched directly background, through normal use.
Comments
Post a Comment