Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"Living in background" by Andrey Skrypnik

"Living in background" by Andrey Skrypnik

During last year Andrey with his team was working hard on creating comprehensive tracking application to enhance user's health & productivity. To achieve smooth user experience he has to manage working in background — seamless network updates, reading sensors data, regions monitoring etc. In this talk Andrey will focus on issues he has faced, expectations vs reality, implementation pitfalls and on the Swift aspect of the application. The last but not least thing to cover will be battery usage — Andrey will reveal some patterns to optimize battery usage even with intensive work with sensors.

This talk was made for CocoaHeads Kyiv #11 which took place March 04 2017.

CocoaHeads Ukraine

March 09, 2017
Tweet

More Decks by CocoaHeads Ukraine

Other Decks in Programming

Transcript

  1. frameworks From concepts to products 1. CoreLocation - where 2.

    CoreMotion - when 3. Background App Refresh - how
  2. Device preprocess first • All device API in hand •

    Ability to use new SDK features • Network optimization From concepts to products
  3. Apple Watch • only in foreground • low battery •

    data synchronize problem (steps/sleeps/etc) From concepts to products
  4. one hand gives the other takes From concepts to products

    • push notifications • emails • popups inside app
  5. From concepts to products • . • Э - -

    . , . Ч ?? • , "В ". • – э ш ( ш ). ( ) • Э . . . э ш . я .
  6. Permissions From concepts to products <key>NSLocationAlwaysUsageDescription</key> <string>Allow permissions for this

    app to ensure accurate tracking</string> <key>NSLocationWhenInUseUsageDescription</key> <string>Allow permissions for this app to ensure accurate tracking</string>
  7. what is under the hood From concepts to products •

    start timers • when back to background
  8. Constants From concepts to products • Walking: • 20 min

    | 1.6 km | 80-140 gps • Automotive: • 30 min | 40 km | 90-150 gps
  9. guaranteed problems From concepts to products • CoreLocation is very

    noisy • You receiving points with inaccurate accuracy even if you set it • Cloudiness has a large affect for accuracy • Time-order for points • different hardware suppliers on same iPhone models
  10. Basic GPS Filter 1. Sort points by time 2. Accuracy

    filter From concepts to products
  11. Basic GPS Filter • Kalman filter • or • Catmullrom

    From concepts to products https://github.com/andrelind/swift-catmullrom
  12. Network 1. collect GPS to 15 points pool 2. calculate

    steps 3. calculate sleeps 1. additionally use phone locks/unlocks 4. use locks for determinate context 1. driver or passenger 2. use phone on work / home 5. 30 sec debounce for sending From concepts to products
  13. statistic From concepts to products 1. start time for work

    – 9:44 2. end time for work – 17:49 (18:03) 3. average commute to work – 1:03:30 4. average commute to home – 31:03 5. average logs per day – 16 6. GPS points in DB – 16.708.814 7. meets – 25641 8. :3