- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if Location Services are enabled in iOS App?
Location services as the name suggests gather the user information via GPS, Wifi and cell towers. Every iOS device has on board GPS, WiFi, cell tower location data and Bluetooth to determine the location of the iPhone or iPad. The user can enable or disable location services from the Settings app by toggling the Location Services switch in General.
You should check the return value of locationServiceEnabled() method before starting location updates to determine whether the user has location services enabled for the current device.
To check if Location Services are enabled in iOS app checkout the code
Open Xcode → New Project in ViewController create new function as below and you’re done.
func isLocationAccessEnabled() { if CLLocationManager.locationServicesEnabled() { switch CLLocationManager.authorizationStatus() { case .notDetermined, .restricted, .denied: print("No access") case .authorizedAlways, .authorizedWhenInUse: print("Access") } } else { print("Location services not enabled") } }
Advertisements