Geofencing in iOS

Geofencing in iOS

Slides from a talk exploring Core Location in iOS through the lense of an app that uses region monitoring (geofencing). Code is at http://git.io/oqlCHQ

F94273df1de7575518ec18b97af43b90?s=128

Kevin McMahon

May 19, 2012
Tweet

Transcript

  1. Geofencing in iOS Kevin McMahon Chicago Code Camp May 19,

    2012 Saturday, May 19, 12
  2. @klmcmahon http://about.me/ kevinmcmahon Saturday, May 19, 12

  3. tl;dr Saturday, May 19, 12

  4. GEOFENCING Saturday, May 19, 12

  5. GEOFENCING? Saturday, May 19, 12

  6. Saturday, May 19, 12

  7. Location-based Services Deeper Integration Saturday, May 19, 12

  8. Location-based Services Deeper Experience Saturday, May 19, 12

  9. Location-based Services Deeper Integration Saturday, May 19, 12

  10. Great! Let’s see it. Saturday, May 19, 12

  11. OK. How did you do it? Saturday, May 19, 12

  12. Core Location Saturday, May 19, 12

  13. Location Information Heading Information Geocoding Region Monitoring Saturday, May 19,

    12
  14. Location Information Heading Information Geocoding Region Monitoring Saturday, May 19,

    12
  15. Location Information Heading Information Geocoding Region Monitoring Saturday, May 19,

    12
  16. Location Information Heading Information Geocoding Region Monitoring Saturday, May 19,

    12
  17. Positioning Methods Saturday, May 19, 12

  18. Saturday, May 19, 12

  19. Saturday, May 19, 12

  20. Location Services Saturday, May 19, 12

  21. Foreground-only Background Significant-change Saturday, May 19, 12

  22. Saturday, May 19, 12

  23. Standard Saturday, May 19, 12

  24. @property CLLocationAccuracy desiredAccuracy; @property CLLocationDistance distanceFilter; - (void)startUpdatingLocation; - (void)stopUpdatingLocation;

    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation; Saturday, May 19, 12
  25. kCLLocationAccuracyBestForNavigation; kCLLocationAccuracyBest; kCLLocationAccuracyNearestTenMeters; kCLLocationAccuracyHundredMeters; kCLLocationAccuracyKilometer; kCLLocationAccuracyThreeKilometers; Saturday, May 19, 12

  26. typedef { CLLocationDegrees latitude; // a double CLLocationDegrees longitude; //

    a double } CLLocationCoordinate2D; @properties CLLocationCoordinate2D coordinate; @property (readonly) CLLocationDistance altitude; @property (readonly) CLLocationAccuracy horizontalAccuracy; @property (readonly) CLLocationAccuracy verticalAccuracy; @property (readonly) CLLocationSpeed speed; // in meters/second @property (readonly) CLLocationDirection course; @property (readonly) NSDate *timestamp; - (CLLocationDistance)distanceFromLocation:(CLLocation *)otherLocation; Saturday, May 19, 12
  27. Significant Change Saturday, May 19, 12

  28. Saturday, May 19, 12

  29. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { id location = [launchOptions

    valueForKey:UIApplicationLaunchOptionsLocationKey]; if(location) { // React to the location update } } Saturday, May 19, 12
  30. Region Monitoring Saturday, May 19, 12

  31. @property (readonly) NSSet *monitoredRegions; - (void)startMonitoringForRegion:(CLRegion *); - (void)startMonitoringForRegion:(CLRegion *)

    desiredAccuracy:(CLLocationAccuracy); - (void)stopMonitoringForRegion:(CLRegion *); // Delegate Methods - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region; - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region; - (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error; Saturday, May 19, 12
  32. Saturday, May 19, 12

  33. typedef enum { kCLErrorLocationUnknown = 0, kCLErrorDenied, kCLErrorNetwork, kCLErrorHeadingFailure, kCLErrorRegionMonitoringDenied,

    kCLErrorRegionMonitoringFailure, kCLErrorRegionMonitoringSetupDelayed } CLError; Saturday, May 19, 12
  34. Considerations Saturday, May 19, 12

  35. Saturday, May 19, 12

  36. Users Saturday, May 19, 12

  37. Devices Saturday, May 19, 12

  38. Use Cases Saturday, May 19, 12

  39. TESTING GPX Files Set Sim Locations UIAutomation Saturday, May 19,

    12
  40. Questions? Saturday, May 19, 12

  41. THANKS! @klmcmahon http://about.me/kevinmcmahon http://git.io/oqlCHQ Saturday, May 19, 12

  42. • http://en.wikipedia.org/wiki/ File:Gps_tracking_geofence.png • http://www.websequencediagrams.com/ CREDITS Saturday, May 19, 12