Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classic - Project 22: locationManager(_ didChangeAuthorization status: CLAuthorizationStatus) was deprecated in iOS 14.0 #67

Open
phatnguyen1006 opened this issue Dec 29, 2021 · 1 comment

Comments

@phatnguyen1006
Copy link

phatnguyen1006 commented Dec 29, 2021

Classic - Project 22: Detect a Beacon.
I see alerts:

  • locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) was deprecated in iOS 14.0

  • locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) was deprecated in iOS 13.0

Maybe need to update below functions in HackingWithSwift/Classic/project22/Project22/ViewController.swift

func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
  if status == .authorizedAlways {
	  if CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self) {
		  if CLLocationManager.isRangingAvailable() {
			  startScanning()
		  }
	  }
  }
}


func locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) {
    if beacons.count > 0 {
	    let beacon = beacons[0]
	    update(distance: beacon.proximity)
    } else {
	    update(distance: .unknown)
    }
}

to

func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
    if manager.authorizationStatus == .authorizedAlways {
        if CLLocationManager.isMonitoringAvailable(for: CLBeaconRegion.self) {
		if CLLocationManager.isRangingAvailable() {
			startScanning()
		}
	}
    }
}

func locationManager(_ manager: CLLocationManager, didRange beacons: [CLBeacon], satisfying beaconConstraint: CLBeaconIdentityConstraint) {
    if beacons.count > 0 {
        let beacon = beacons[0]
        update(distance: beacon.proximity)
    } else {
        update(distance: .unknown)
    }
}
@phatnguyen1006
Copy link
Author

phatnguyen1006 commented Dec 29, 2021

Im trying change functions in #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant