iphone - How to walk the line between location accuracy and power efficiency? -
i working on app requires work in foreground , background , send location data. haven't written code yet , familiarized myself how corelocation works determine approach follow. reading did far, gather that:
with startmonitoringsignificantlocationchanges
the gps never activated it calls didupdatelocations (or didupdatetolocation ios<6) when alter of radio tower detected the desiredaccuracy , distancefilter properties both ignoredwith startupdatinglocation
the battery drain higher didupdatelocations called whenever hardware phone has info provide. , because there multiple hardware components can used location (gps, radio, wifi), there no guarantee when or how didupdatelocations called, or whether new reading more accurate previous 1 even the first number(s) bad because not rely on gps there no sure way of knowing whether have best location ever get: matter of picking among locations received 1 best accuracy in given time window availablei don't see much give-and-take or documentation intermediate route. if want power-conscious reasonably accurate info when user has moved significantly? seems possible compromise approach to:
turn on startmonitoringsignificantlocationchanges switch using startupdatinglocation when didupdatelocations called wait short while give chance gps readings , select 1 best accuracy switch using startmonitoringsignificantlocationchanges , on...as far know, approach work same in foreground , background , provide compromise between 2 standard approaches supported apple.
questions: - understanding right , "compromise" approach sound? - has used approach successfully? - caveats approach? - there improve compromise approach out there?
ps: imagine later refine approach take business relationship estimated travel speed don't utilize gps when person traveling.
there various ways go problem, , ranges how complex want battery-conscious code get. simplest solution using gps, can complicated fast, such taking samples every x amount of time, find accurate, predict user in time leading next sample using previous samples, etc.
the thought of compromise fine, need factor in how much want users utilize app, how long running for, , how accurate need info be. in end, come downwards trial , error in figuring out best combination of gps , rough info is. should know important changes don't occur often, that's relative. if app depends on users driving in auto @ 60mph, might not take long, if walking around, can take much, much longer trigger important alter (if ever). i have not used approach before, apps i've done corelocation require accurate location info short period of time. the caveats approach take lots of trial , error, , may cut down performance of app. before start coding this, should figure out if time making work pay off in end. in addition, if decide figure out user traveling based on samples, need figure out if saves battery - calculations pretty expensive battery-wise. honestly, corelocation isn't big of battery hog, , apple improving it's energy use. example, @ moves ios. user of it, can battery effect none, , it's using location 24/7.if i'm not mistaken, instruments allow monitor battery usage, can utilize if decide compromise aid in trial , error.
hope helped!
iphone cocoa-touch core-location cllocationmanager background-process
No comments:
Post a Comment