Upload
goran-blazic
View
86
Download
3
Tags:
Embed Size (px)
Citation preview
So, who are you again?• pro software engineer for 2 decades
• iOS / OS X oriented for the past 6 years most of that time freelancing
• co-founder of and coach at CodeCatz major project: http://events.codeweek.eu
• just get on with it!! ain’t nobody got time for that
iOS Background Fetch?
• API introduced in iOS 7
• Allows apps to fetch data while in background
• Yes, even when device is in standby mode
• Heavily regulated by iOS - hard to predict
Hard to predict…• iOS decides when app should fetch data
• Users device use patterns
• Device connectivity
• Battery level
• Phase of the moon - probably 😇
Why use it?
• Data is available when user runs app!
• Battery life increase in the long run (at least, that’s what Apple claims)
• Overall user experience => happy users
How? Where? What?• Add “UIBackgroundModes” array to Info.plist
a.k.a. “Required background modes”
• Add “fetch” to array key a.k.a. “App downloads content from the network”
What about the code?• Call a method on UIApplication:
setMinimumBackgroundFetchInterval:Best done in AppDelegate: application:didFinishLaunchingWithOptions:
• Pass minimum amount of seconds between fetch calls
• minimum amount is just a pointer, though… it really is unpredictable
Is that it? Then what?• iOS calls a method on our AppDelegate:
application:performFetchWithCompletionHandler:
• method has 30 seconds to fetch data and call completion handler
• method should return meaningful result to iOS
• result influences pattern of future fetch calls
Just show the code, or do a demo,
or something!Might be easier 😏
code is available on github
https://github.com/goranche/backgroundSync