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

Privacy, State of the Union, July '20, Bitrise ...

Privacy, State of the Union, July '20, Bitrise User Group

Inspired from my a book about Privacy:
https://www.apress.com/gp/book/9781484242902

Recorded @ https://youtu.be/kNRopFbqGaQ?t=1843

Apple has brought us a lot of new things about #Privacy this year and I'm showing you specifically the new stuff about Photos, Location and Contacts.

That being said, I'm also emphasizing on what should come in iOS 15, since they're not done yet for me...

Enjoy and let me know of any questions on Twitter or let me know if I could present this to your conference or meetup!

Manu Carrasco Molina

July 02, 2020
Tweet

More Decks by Manu Carrasco Molina

Other Decks in Programming

Transcript

  1. > who/whyami? ✋ " speaking # guy born in $

    living in for 17 years ✋ 23 years ( ) as a dev, 12 with #techs ✋ 9 years of political involvement with the #party ✋ 5 years of climate - & refugees #activism ✋ 6 / years 0 without 1 meat, half of it #vegan @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 2
  2. Ethics FTW This talk is about Karma @stuffmc • Privacy,

    State of the Union, July '20, Bitrise User Group 3
  3. 4

  4. We will cover ✋ Photos & Cameras ✋ Location &

    MapKit ✋ Contacts @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 5
  5. More in the book ✋ Calendar & Events ✋ Health

    & Fitness ✋ Siri & Search ✋ HomeKit @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 6
  6. i/macOS versions Just like the book, this talk assumes you

    build for at least iOS 11. Ideally iOS 13, and yes, we'll of course look at iOS 14! As for macOS, ideally macOS 10.15 (Catalina) but we might talk about Big Sur / macOS 11. @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 7
  7. Access the library PHPhotoLibrary.requestAuthorization { status in enum PHAuthorizationStatus {

    @available(iOS 8, *) case notDetermined = 0 // User has not yet made a choice case restricted = 1 // Application not authorized to access photos (Parental Control?) case denied = 2 // User has explicitly denied this application access to photos case authorized = 3 // User has authorized this application @available(iOS 14, *) case limited = 4 // User has authorized this application for limited photo library access. } } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 10
  8. Select more... {} PHPhotoLibraryPreventAutomaticLimitedAccessAlert = YES to the application's Info.plist

    to prevent the automatic alert to update the users limited library selection. @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 11
  9. Pick 1 & only 1 let picker = UIImagePickerController() //

    This is in UIKit (What?!) picker.sourceType = .photoLibrary // or .camera, or .savedPhotosAlbum // UIImagePickerControllerDelegate & UINavigationControllerDelegate picker.delegate = self present(picker, animated: true) { } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 12
  10. Picker Delegate func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey :

    Any]) { defer { picker.dismiss(animated: true) } info.originalImage // a UIImage info.editedImage // a UIImage info.imageURL // an NSURL info.phAsset: UIImagePickerController.InfoKey // a PHAsset // Will be removed in a future release, use PHPicker in iOS 14. } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 13
  11. Limited PHPhotoLibrary.shared() .presentLimitedLibraryPicker(from: self) ✋ New in iOS14! ✋ Finally

    multiple selections! ✋ Built in Preview @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 15
  12. Save ! & ✋ start/stopLocation? requestLocation! 1 ✋ Region Monitoring

    instead of checking location! ✋ Lower location accuracy (to 3 KM if you can) 1 ... and Don't forget to Stop, when you get enough! Find My talk about Energy Optimization @ speakerdeck.com Z. Veselinovic (CC BY-SA 2.0) 17
  13. Authorization var status: CLAuthorizationStatus if #available(iOS 14.0, *) { status

    = locationManager.authorizationStatus() } else { status = CLLocationManager.authorizationStatus() } // Deprecated. Use the instance property authorizationStatus instead. open class func authorizationStatus() -> CLAuthorizationStatus open func authorizationStatus() -> CLAuthorizationStatus @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 18
  14. Statuses enum CLAuthorizationStatus { case notDetermined = 0 case restricted

    = 1 case denied = 2 case authorizedAlways = 3 case authorizedWhenInUse = 4 } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 19
  15. iOS 12, 13, or 14? ✋ Allow once is new

    since iOS 13 ✋ Region Monitoring needs Always in iOS 12 ✋ Yes, it's a mess... But wait, there's more... ✋ Try to move to current (not Beta!) every year just after WWDC ✋ It's your chance to clean your code @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 20
  16. Accuracy // The location service will try its best //

    to achieve your desired accuracy. // However, it is not guaranteed. // To optimize power performance, ... typealias CLLocationAccuracy = Double // In meters/second. // The lower the value the more precise the speed is typealias CLLocationSpeedAccuracy = Double @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 21
  17. ↘ Accuracy  The locations you receive will match the

    locations your app would have received if the user had decided not to grant your app authorization for precise location. @available(iOS 14.0, *) public let kCLLocationAccuracyReduced: CLLocationAccuracy @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 23
  18. Full or reduced @available(iOS, introduced: 14.0, deprecated: 14.0) open var

    isAuthorizedForPreciseLocation: Bool { get } @available(iOS 14.0, *) open var accuracyAuthorization: CLAccuracyAuthorization { get } public enum CLAccuracyAuthorization : Int { // This application has the user's permission to receive accurate location information. case fullAccuracy = 0 // See Next slide case reducedAccuracy = 1 } } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 24
  19. FIVE Kilometers The user has chosen to grant this application

    access to location information with reduced accuracy. Region monitoring and beacon ranging are not available to the application. Other CoreLocation APIs are available with reduced accuracy. Location estimates will have a horizontalAccuracy on the order of about 5km. Applications should be prepared to receive locations that are up to 20 minutes old. @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 25
  20. Good, Bad func good() { let descriptors = [ CNContactGivenNameKey,

    CNContactFamilyNameKey ] predicate(with: descriptors) } func bad() { predicate(with: descriptors) } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 29
  21. Nice, but no API @stuffmc • Privacy, State of the

    Union, July '20, Bitrise User Group 30
  22. func predicate(with descriptors: [CNKeyDescriptor]) { let alert = UIAlertController(...) alert.addTextField

    { $0.text = "Bell" } alert.addAction( UIAlertAction(title: "Search", style: .default, handler: { (_) in self.allow(with: CNContact.predicateForContacts( matchingName: alert.textFields?.first?.text ?? ""), for: descriptors) })) present(alert, animated: true) } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 31
  23. func allow(with predicate: NSPredicate, for descriptors: [CNKeyDescriptor]) { CNContactStore().requestAccess(for: .contacts)

    { (success, error) in let status = CNContactStore.authorizationStatus(for: .contacts) (...) let fetchRequest = CNContactFetchRequest(keysToFetch: descriptors) fetchRequest.predicate = predicate self.contacts = try self.store.unifiedContacts(matching: predicate, keysToFetch: descriptors) self.showContacts(for: status) (...) } } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 32
  24. Ugly func ugly() { let predicate = CNContact.predicateForContactsInContainer(withIdentifier: store.defaultContainerIdentifier()) allow(with:

    predicate, for: descriptors) } @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 33
  25. Contact Picker let picker = CNContactPickerViewController() picker.delegate = sender.tag ==

    1 ? contactVC : self present(picker, animated: true) { } func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: [CNContact]) func contactPicker(_ picker: CNContactPickerViewController, didSelect contacts: [CNContact]) @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 34
  26. New-isch in iOS 14 ✋ Proactive keyboard ✋ Autofill everywhere

    ✋ Think about granularity textFieldOrView.textContentType = .emailAddress .telephoneNumber .fullStreetAddress .addressCity @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 35
  27. References ✋ Build trust through better privacy ✋ Design for

    location privacy ✋ Handle the Limited Photos Library in your app ✋ Meet the new Photos picker ✋ What's new in location ✋ Autofill everywhere + Look for "Privacy" @ Past DubDubs @stuffmc • Privacy, State of the Union, July '20, Bitrise User Group 36