-
Build location-aware enterprise apps
Develop location-aware enterprise apps for your business and personalize your employee's everyday experience. Learn how Apple built the Caffe Macs app for its on-campus cafeterias using iBeacons and Location Services and how you can apply these tools and frameworks to your own apps, while preserving employee privacy. From there, discover how you can use localization to deliver a great experience for your international employees.
Recursos
Videos relacionados
WWDC20
- Build localization-friendly layouts using Xcode
- Design for location privacy
- Formatters: Make data human-friendly
- What's new in location
WWDC19
-
Buscar este video…
-
-
3:28 - Preferences: User-defined Preferred Location
// Storing the user’s preference using UserDefaults UserDefaults.standard.set(defaultLocation.id, forKey: "defaultLocationId") let defaultLocationId = UserDefaults.standard.integer(forKey: "defaultLocationId") -
6:14 - Location Services: Requesting Authorization
// Add NSLocationWhenInUseUsageDescription to your Info.plist // e.g. “Location is required for placing orders while using the app." locationManager.requestWhenInUseAuthorization() func locationManager( _ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { switch status { case .restricted, .denied: disableLocationFeatures() case .authorizedWhenInUse, .authorizedAlways: enableLocationFeatures() case .notDetermined: // The user hasn’t chosen an authorization status } } -
7:02 - Location Services: Determining Device Support
if CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self) { // Supports region monitoring to detect beacon regions } if CLLocationManager.isRangingAvailable() { // Supports obtaining the relative distance to a nearby iBeacon device } -
8:54 - Stage 1: Region Monitoring
// Stage 1: Region Monitoring func monitorBeacons() { if CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self) { let constraint = CLBeaconIdentityConstraint(uuid: proximityUUID) let beaconRegion = CLBeaconRegion( beaconIdentityConstraint: constraint, identifier: beaconID ) self.locationManager.startMonitoring(for: beaconRegion) } } -
9:30 - Stage 2: Beacon Ranging
// Stage 2: Beacon Ranging func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { guard let region = region as? CLBeaconRegion, CLLocationManager.isRangingAvailable() else { return } let constraint = CLBeaconIdentityConstraint(uuid: region.uuid) manager.startRangingBeacons(satisfying: constraint) beaconsToRange.append(region) } func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { } -
10:09 - Stage 2: Beacon Ranging
// Stage 2: Beacon Ranging func locationManager( _ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) { guard let nearestBeacon = beacons.first else { return } let major = CLBeaconMajorValue(truncating: nearestBeacon.major) let minor = CLBeaconMinorValue(truncating: nearestBeacon.major) switch nearestBeacon.proximity { case .near, .immediate: displayInformation(for: major, and: minor) default: handleUnknownOrFarBeacon(for: major, and: minor) } } -
11:32 - Formatting Dates
// Formatting Dates let dateFormatter = DateFormatter() dateFormatter.dateStyle = .medium dateFormatter.timeStyle = .short dateFormatter.string(from: Date()) // "Jun 25, 2020 at 9:41 AM" -
12:41 - Configuring the Format of Currency
// Configuring the Format of Currency let formatter = NumberFormatter() formatter.currencyCode = "CAD" formatter.numberStyle = .currency formatter.string(from: amount) // "CA$1.00"
-