SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
iOS 7 URL Session & Motion FX
APIs
@rsebbe
@creaceed@cocoaheadsBE
URL SESSION
• New in iOS 7 and OS X 10.9
• Preferred API for (up/down-)loading URL contents
• Many use case scenarios. Get URL contents as NSData or file,
background download/upload, cookie/cache/authentication
handling, etc.
• This talk is about background downloads only
• You should check AFNetworking 2.0.Was just released!
URL SESSION
• URL Session types: Default, Ephemeral, Background
• App initiates a download (in process)
• iOS handles it for you (out of process)
• Apps gets notified/restarted when finished
URL SESSION
• What happens when:
- App is iOS-terminated in the background? Download continues.
- Rebooting the phone? Download continues.
- App killed by user? Download is aborted.
• And when download finishes?
- Your app is restarted (if not running) to handle it.
URL SESSION
NSURLSession
NSURLSessionDownloadTask
com.creaceed.iprizmo.ocrdata
com.creaceed.iprizmo.voices
NSURLSession
NSURLSessionDownloadTask
NSURLSessionDownloadTask
Dutch OCR Data.zip
French OCR Data.zip
Graham (British EnglishVoice).zip
URL SESSION
Prepare Session
Initiate Download Task
App Killed (for some reason)
Download finishes
App restarted
Prepare Session (same id)
[retrieve pending tasks, if needed]
Notify Completion
Handle download
URL SESSION
urlSessionQueue = [NSOperationQueue mainQueue];
! ! !
configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:
! [PRSpeechController urlSessionIdentifier]];
configuration.discretionary = YES;
urlSession = [NSURLSession sessionWithConfiguration:configuration
! delegate:self delegateQueue:urlSessionQueue];
[self.urlSession getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray
*uploadTasks, NSArray *downloadTasks) {
! for(NSURLSessionDownloadTask *task in downloadTasks) {
! if(task.state == NSURLSessionTaskStateRunning) {
! ! }
! }
}];
- (void)URLSession:(NSURLSession *)session downloadTask:
(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten
totalBytesWritten:(int64_t)cur totalBytesExpectedToWrite:(int64_t)tot
- (void)URLSession:(NSURLSession *)session downloadTask:
(NSURLSessionDownloadTask *)downloadTask
didResumeAtOffset:(int64_t)fileOffset
expectedTotalBytes:(int64_t)expectedTotalBytes
URL SESSION
- (void)application:(UIApplication *)application
handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:
(void (^)())completionHandler
{
! if([identifier isEqualToString:[PRSpeechController urlSessionIdentifier]])
! {
! ! EX_ASSERT(self.speechController != nil);
! ! self.speechController.backgroundDownloadCompletionHandler =
completionHandler;
! }
}
- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession
*)session {
! // do some work, then:
! if(self.backgroundDownloadCompletionHandler) {
! ! self.backgroundDownloadCompletionHandler();
! ! self.backgroundDownloadCompletionHandler = nil;
! }
}
TIPS &TRICKS
• Download tasks cannot use completion handler for background
session.Why? Because app process can be killed at any time! Use
delegate methods.
• You should immediately copy the downloaded file somewhere.
• You need to identify the finished download. Parse the URL? No.
There’s a better (& well hidden) solution:
• If your app is restarted, you can delay the call to the OS-passed
completion handler until you have finished processing.
[NSURLProtocol setProperty:voiceKey forKey:@"voiceKey" inRequest:request];
MOTION EFFECTS
MOTION EFFECTS
• Parallax: Objects move at
different speed depending on
their distance to viewer
• iOS does not track your eyes,
but gyroscope provides a good
approximation of relative
viewer position.
• With that information, you can
simulate the parallax effect by
moving contents
A
B
MOTION EFFECTS
• UIMotionEffect, that you can subclass
@interface CRParallaxMotionEffect : UIMotionEffect
- (NSDictionary *)keyPathsAndRelativeValuesForViewerOffset:(UIOffset)viewerOffset
{
! return @{@”center”: [NSValue valueWithCGPoint:
CGPointMake(viewerOffset.horizontal*10, viewerOffset.vertical*10)]};
}
[view addMotionEffect:parallaxEffect];
MOTION EFFECTS
• UIInterpolatingMotionEffect, to interpolate values along X orY
axis
• UIMotionEffectGroup, to sync multiple motion effects together
! UIInterpolatingMotionEffect *imfx = [[UIInterpolatingMotionEffect alloc]
! ! ! initWithKeyPath:@"center"
! type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
! imfx.maximumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(15,0)];
! imfx.minimumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(-15,0)];
! [view addMotionEffect:imfx];
! UIInterpolatingMotionEffect *imfy = [[UIInterpolatingMotionEffect alloc]
! ! ! initWithKeyPath:@"center"
type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
! imfy.maximumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(0,15)];
! imfy.minimumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(0,-15)];
! [view addMotionEffect:imfy];
TIPS &TRICKS
• We used the first approach, add effect with single line of code
• CRParallaxMotionEffect available on GitHub: http://bit.ly/prllx
[view addMotionEffect:[CRParallaxMotionEffect parallaxEffectWithAmplitude:10.0]];
TIPS &TRICKS
• Make moving views bigger!
• For scrollviews, use ‘contentOffset’, but with motion in the
opposite direction (negate amplitude)
• Not only points, but also colors, shadow offset, layer
properties, 2D and 3D transforms.
view.frame = CGRectInset(container.bounds, -10.0, -10.0);
DEMO

Contenu connexe

Tendances

Micro Services - Neither Micro Nor Service
Micro Services - Neither Micro Nor ServiceMicro Services - Neither Micro Nor Service
Micro Services - Neither Micro Nor ServiceEberhard Wolff
 
Micro Service – The New Architecture Paradigm
Micro Service – The New Architecture ParadigmMicro Service – The New Architecture Paradigm
Micro Service – The New Architecture ParadigmEberhard Wolff
 
Using The Right Tool For The Job
Using The Right Tool For The JobUsing The Right Tool For The Job
Using The Right Tool For The JobChris Baldock
 
Java Application Servers Are Dead!
Java Application Servers Are Dead!Java Application Servers Are Dead!
Java Application Servers Are Dead!Eberhard Wolff
 
Intro to Electron - Creating Desktop Applications with HTML5
Intro to Electron - Creating Desktop Applications with HTML5Intro to Electron - Creating Desktop Applications with HTML5
Intro to Electron - Creating Desktop Applications with HTML5Felicia O'Garro
 
CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsMike North
 
Packer, Terraform, Ansible avec Azure
Packer, Terraform, Ansible avec AzurePacker, Terraform, Ansible avec Azure
Packer, Terraform, Ansible avec AzureAZUG FR
 
Developing Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring CloudDeveloping Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring CloudDustin Ruehle
 
Continuous Delivery and Micro Services - A Symbiosis
Continuous Delivery and Micro Services - A SymbiosisContinuous Delivery and Micro Services - A Symbiosis
Continuous Delivery and Micro Services - A SymbiosisEberhard Wolff
 
Spring Boot
Spring BootSpring Boot
Spring Bootgedoplan
 
Microservice - All is Small, All is Well?
Microservice - All is Small, All is Well?Microservice - All is Small, All is Well?
Microservice - All is Small, All is Well?Eberhard Wolff
 
Phonegap - An Introduction
Phonegap - An IntroductionPhonegap - An Introduction
Phonegap - An IntroductionTyler Johnston
 
Prometheus Celery Exporter
Prometheus Celery ExporterPrometheus Celery Exporter
Prometheus Celery ExporterFabio Todaro
 
Java Architectures - a New Hope
Java Architectures - a New HopeJava Architectures - a New Hope
Java Architectures - a New HopeEberhard Wolff
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideMohanraj Thirumoorthy
 
Performance Metrics for your Build Pipeline - presented at Vienna WebPerf Oct...
Performance Metrics for your Build Pipeline - presented at Vienna WebPerf Oct...Performance Metrics for your Build Pipeline - presented at Vienna WebPerf Oct...
Performance Metrics for your Build Pipeline - presented at Vienna WebPerf Oct...Andreas Grabner
 
In the hunt of 100% delivery rate with mobile push notifications
In the hunt of 100% delivery rate with mobile push notificationsIn the hunt of 100% delivery rate with mobile push notifications
In the hunt of 100% delivery rate with mobile push notificationsJan Haložan
 
Continous integration and delivery for single page applications
Continous integration and delivery for single page applicationsContinous integration and delivery for single page applications
Continous integration and delivery for single page applicationsSunil Dalal
 

Tendances (20)

Legacy Sins
Legacy SinsLegacy Sins
Legacy Sins
 
Micro Services - Neither Micro Nor Service
Micro Services - Neither Micro Nor ServiceMicro Services - Neither Micro Nor Service
Micro Services - Neither Micro Nor Service
 
Micro Service – The New Architecture Paradigm
Micro Service – The New Architecture ParadigmMicro Service – The New Architecture Paradigm
Micro Service – The New Architecture Paradigm
 
Using The Right Tool For The Job
Using The Right Tool For The JobUsing The Right Tool For The Job
Using The Right Tool For The Job
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
Java Application Servers Are Dead!
Java Application Servers Are Dead!Java Application Servers Are Dead!
Java Application Servers Are Dead!
 
Intro to Electron - Creating Desktop Applications with HTML5
Intro to Electron - Creating Desktop Applications with HTML5Intro to Electron - Creating Desktop Applications with HTML5
Intro to Electron - Creating Desktop Applications with HTML5
 
CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page Apps
 
Packer, Terraform, Ansible avec Azure
Packer, Terraform, Ansible avec AzurePacker, Terraform, Ansible avec Azure
Packer, Terraform, Ansible avec Azure
 
Developing Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring CloudDeveloping Resilient Cloud Native Apps with Spring Cloud
Developing Resilient Cloud Native Apps with Spring Cloud
 
Continuous Delivery and Micro Services - A Symbiosis
Continuous Delivery and Micro Services - A SymbiosisContinuous Delivery and Micro Services - A Symbiosis
Continuous Delivery and Micro Services - A Symbiosis
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Microservice - All is Small, All is Well?
Microservice - All is Small, All is Well?Microservice - All is Small, All is Well?
Microservice - All is Small, All is Well?
 
Phonegap - An Introduction
Phonegap - An IntroductionPhonegap - An Introduction
Phonegap - An Introduction
 
Prometheus Celery Exporter
Prometheus Celery ExporterPrometheus Celery Exporter
Prometheus Celery Exporter
 
Java Architectures - a New Hope
Java Architectures - a New HopeJava Architectures - a New Hope
Java Architectures - a New Hope
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
 
Performance Metrics for your Build Pipeline - presented at Vienna WebPerf Oct...
Performance Metrics for your Build Pipeline - presented at Vienna WebPerf Oct...Performance Metrics for your Build Pipeline - presented at Vienna WebPerf Oct...
Performance Metrics for your Build Pipeline - presented at Vienna WebPerf Oct...
 
In the hunt of 100% delivery rate with mobile push notifications
In the hunt of 100% delivery rate with mobile push notificationsIn the hunt of 100% delivery rate with mobile push notifications
In the hunt of 100% delivery rate with mobile push notifications
 
Continous integration and delivery for single page applications
Continous integration and delivery for single page applicationsContinous integration and delivery for single page applications
Continous integration and delivery for single page applications
 

Similaire à iOS 7 URL Session & Motion FX APIs

Mobile Devices
Mobile DevicesMobile Devices
Mobile DevicesYnon Perek
 
MOCA iBeacons SDK for iOS 7
MOCA iBeacons SDK for iOS 7MOCA iBeacons SDK for iOS 7
MOCA iBeacons SDK for iOS 7MOCA Platform
 
10 Must-Use Components for Your Mobile Apps, James Clancey
10 Must-Use Components for Your Mobile Apps, James Clancey10 Must-Use Components for Your Mobile Apps, James Clancey
10 Must-Use Components for Your Mobile Apps, James ClanceyXamarin
 
[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache CordovaIvano Malavolta
 
Introduction to PhoneGap
Introduction to PhoneGapIntroduction to PhoneGap
Introduction to PhoneGapRamesh Nair
 
Couchbase Mobile Ideathon in Tokyo 2014.08.29: Developing with couchbase lite
Couchbase Mobile Ideathon in Tokyo 2014.08.29: Developing with couchbase lite Couchbase Mobile Ideathon in Tokyo 2014.08.29: Developing with couchbase lite
Couchbase Mobile Ideathon in Tokyo 2014.08.29: Developing with couchbase lite Keiko Ogura
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQLKonstantin Gredeskoul
 
Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)danielputerman
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGapChristian Rokitta
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
PhoneGap - Now and the Future
PhoneGap - Now and the FuturePhoneGap - Now and the Future
PhoneGap - Now and the FutureTim Kim
 
Android development war stories
Android development war storiesAndroid development war stories
Android development war storiesLope Emano
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaChristian Heilmann
 

Similaire à iOS 7 URL Session & Motion FX APIs (20)

Mobile Devices
Mobile DevicesMobile Devices
Mobile Devices
 
Firebase slide
Firebase slideFirebase slide
Firebase slide
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
MOCA iBeacons SDK for iOS 7
MOCA iBeacons SDK for iOS 7MOCA iBeacons SDK for iOS 7
MOCA iBeacons SDK for iOS 7
 
10 Must-Use Components for Your Mobile Apps, James Clancey
10 Must-Use Components for Your Mobile Apps, James Clancey10 Must-Use Components for Your Mobile Apps, James Clancey
10 Must-Use Components for Your Mobile Apps, James Clancey
 
[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache Cordova
 
Introduction to PhoneGap
Introduction to PhoneGapIntroduction to PhoneGap
Introduction to PhoneGap
 
Couchbase Mobile Ideathon in Tokyo 2014.08.29: Developing with couchbase lite
Couchbase Mobile Ideathon in Tokyo 2014.08.29: Developing with couchbase lite Couchbase Mobile Ideathon in Tokyo 2014.08.29: Developing with couchbase lite
Couchbase Mobile Ideathon in Tokyo 2014.08.29: Developing with couchbase lite
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
PhoneGap - Now and the Future
PhoneGap - Now and the FuturePhoneGap - Now and the Future
PhoneGap - Now and the Future
 
Apache cordova
Apache cordovaApache cordova
Apache cordova
 
Expo Router V2
Expo Router V2Expo Router V2
Expo Router V2
 
Android development war stories
Android development war storiesAndroid development war stories
Android development war stories
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
 
Apache Oozie
Apache OozieApache Oozie
Apache Oozie
 

Plus de rsebbe

Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Codersebbe
 
Advanced Imaging on iOS
Advanced Imaging on iOSAdvanced Imaging on iOS
Advanced Imaging on iOSrsebbe
 
CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...rsebbe
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCDrsebbe
 
Designing an Objective-C Framework about 3D
Designing an Objective-C Framework about 3DDesigning an Objective-C Framework about 3D
Designing an Objective-C Framework about 3Drsebbe
 
Computer-aided Diagnosis of Pulmonary Embolism in Opacified CT Images
Computer-aided Diagnosis of Pulmonary Embolism in Opacified CT ImagesComputer-aided Diagnosis of Pulmonary Embolism in Opacified CT Images
Computer-aided Diagnosis of Pulmonary Embolism in Opacified CT Imagesrsebbe
 
Xcode, Basics and Beyond
Xcode, Basics and BeyondXcode, Basics and Beyond
Xcode, Basics and Beyondrsebbe
 

Plus de rsebbe (7)

Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Code
 
Advanced Imaging on iOS
Advanced Imaging on iOSAdvanced Imaging on iOS
Advanced Imaging on iOS
 
CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
 
Designing an Objective-C Framework about 3D
Designing an Objective-C Framework about 3DDesigning an Objective-C Framework about 3D
Designing an Objective-C Framework about 3D
 
Computer-aided Diagnosis of Pulmonary Embolism in Opacified CT Images
Computer-aided Diagnosis of Pulmonary Embolism in Opacified CT ImagesComputer-aided Diagnosis of Pulmonary Embolism in Opacified CT Images
Computer-aided Diagnosis of Pulmonary Embolism in Opacified CT Images
 
Xcode, Basics and Beyond
Xcode, Basics and BeyondXcode, Basics and Beyond
Xcode, Basics and Beyond
 

Dernier

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Dernier (20)

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

iOS 7 URL Session & Motion FX APIs

  • 1. iOS 7 URL Session & Motion FX APIs @rsebbe @creaceed@cocoaheadsBE
  • 2. URL SESSION • New in iOS 7 and OS X 10.9 • Preferred API for (up/down-)loading URL contents • Many use case scenarios. Get URL contents as NSData or file, background download/upload, cookie/cache/authentication handling, etc. • This talk is about background downloads only • You should check AFNetworking 2.0.Was just released!
  • 3. URL SESSION • URL Session types: Default, Ephemeral, Background • App initiates a download (in process) • iOS handles it for you (out of process) • Apps gets notified/restarted when finished
  • 4. URL SESSION • What happens when: - App is iOS-terminated in the background? Download continues. - Rebooting the phone? Download continues. - App killed by user? Download is aborted. • And when download finishes? - Your app is restarted (if not running) to handle it.
  • 6. URL SESSION Prepare Session Initiate Download Task App Killed (for some reason) Download finishes App restarted Prepare Session (same id) [retrieve pending tasks, if needed] Notify Completion Handle download
  • 7. URL SESSION urlSessionQueue = [NSOperationQueue mainQueue]; ! ! ! configuration = [NSURLSessionConfiguration backgroundSessionConfiguration: ! [PRSpeechController urlSessionIdentifier]]; configuration.discretionary = YES; urlSession = [NSURLSession sessionWithConfiguration:configuration ! delegate:self delegateQueue:urlSessionQueue]; [self.urlSession getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { ! for(NSURLSessionDownloadTask *task in downloadTasks) { ! if(task.state == NSURLSessionTaskStateRunning) { ! ! } ! } }]; - (void)URLSession:(NSURLSession *)session downloadTask: (NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)cur totalBytesExpectedToWrite:(int64_t)tot - (void)URLSession:(NSURLSession *)session downloadTask: (NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes
  • 8. URL SESSION - (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler: (void (^)())completionHandler { ! if([identifier isEqualToString:[PRSpeechController urlSessionIdentifier]]) ! { ! ! EX_ASSERT(self.speechController != nil); ! ! self.speechController.backgroundDownloadCompletionHandler = completionHandler; ! } } - (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { ! // do some work, then: ! if(self.backgroundDownloadCompletionHandler) { ! ! self.backgroundDownloadCompletionHandler(); ! ! self.backgroundDownloadCompletionHandler = nil; ! } }
  • 9. TIPS &TRICKS • Download tasks cannot use completion handler for background session.Why? Because app process can be killed at any time! Use delegate methods. • You should immediately copy the downloaded file somewhere. • You need to identify the finished download. Parse the URL? No. There’s a better (& well hidden) solution: • If your app is restarted, you can delay the call to the OS-passed completion handler until you have finished processing. [NSURLProtocol setProperty:voiceKey forKey:@"voiceKey" inRequest:request];
  • 11. MOTION EFFECTS • Parallax: Objects move at different speed depending on their distance to viewer • iOS does not track your eyes, but gyroscope provides a good approximation of relative viewer position. • With that information, you can simulate the parallax effect by moving contents A B
  • 12. MOTION EFFECTS • UIMotionEffect, that you can subclass @interface CRParallaxMotionEffect : UIMotionEffect - (NSDictionary *)keyPathsAndRelativeValuesForViewerOffset:(UIOffset)viewerOffset { ! return @{@”center”: [NSValue valueWithCGPoint: CGPointMake(viewerOffset.horizontal*10, viewerOffset.vertical*10)]}; } [view addMotionEffect:parallaxEffect];
  • 13. MOTION EFFECTS • UIInterpolatingMotionEffect, to interpolate values along X orY axis • UIMotionEffectGroup, to sync multiple motion effects together ! UIInterpolatingMotionEffect *imfx = [[UIInterpolatingMotionEffect alloc] ! ! ! initWithKeyPath:@"center" ! type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; ! imfx.maximumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(15,0)]; ! imfx.minimumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(-15,0)]; ! [view addMotionEffect:imfx]; ! UIInterpolatingMotionEffect *imfy = [[UIInterpolatingMotionEffect alloc] ! ! ! initWithKeyPath:@"center" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis]; ! imfy.maximumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(0,15)]; ! imfy.minimumRelativeValue = [NSValue valueWithCGPoint:CGPointMake(0,-15)]; ! [view addMotionEffect:imfy];
  • 14. TIPS &TRICKS • We used the first approach, add effect with single line of code • CRParallaxMotionEffect available on GitHub: http://bit.ly/prllx [view addMotionEffect:[CRParallaxMotionEffect parallaxEffectWithAmplitude:10.0]];
  • 15. TIPS &TRICKS • Make moving views bigger! • For scrollviews, use ‘contentOffset’, but with motion in the opposite direction (negate amplitude) • Not only points, but also colors, shadow offset, layer properties, 2D and 3D transforms. view.frame = CGRectInset(container.bounds, -10.0, -10.0);
  • 16. DEMO