CLLocationManager ব্যবহার করে লোকেশন পারমিশন রিকোয়েস্ট করুন।
var locationManager = CLLocationManager()
লোকেশন সার্ভিস সক্রিয় কিনা চেক করুন —
if CLLocationManager.locationServicesEnabled() {
print("permissions allowed")
} else {
locationManager.requestAlwaysAuthorization()
locationManager.requestWhenInUseAuthorization()
}
অথরাইজেশন স্ট্যাটাস চেক —
if CLLocationManager.locationServicesEnabled() {
switch CLLocationManager.authorizationStatus() {
case .authorizedAlways, .authorizedWhenInUse: print("authorized.")
case .denied, .restricted, .notDetermined: print("not authorized.")
}
}
অথরাইজেশন স্ট্যাটাস enum: notDetermined, restricted, denied, authorizedAlways, authorizedWhenInUse।