Mobile applications ask permissions to access user’s information or user’s phone features. These permissions can be accessing camera, microphone, location, phone contact list, calendars, photos, reminders etc.
You should define your permission asking strategy wisely. You can prefer either asking permission right before using this-exact feature or you can show information why you really need these permissions and direct your users to your application’s settings page or both. If a user will not continue using your app without giving permissions, it’s nice to show information why you need it and what your application offers the user by using these features, then direct users your application settings page.
After iOS8 release, when any of iOS applications permission settings, is changed, application is killed by operating system and started with new permission settings. So if your user changes camera permission, for instance, and launch your app again, she or he will see your app’s first page instead of the current page your application which your app asked her/him permission. So your user starts again. If the app will ask more than one permission consecutively, you may think to inform your user before getting first permission and then direct her or him to your application settings, so she/he give all needed permissions at once.
I will share sample project after I give some keys and talk about main logic.
First, you should add your usage descriptions for tracking location, either one of always or when-in-use situation or both.
All you have to do, import CoreLocation framework and check authorizationStatus of your app. Logic is simple:
- If it’s not determined, for trigger system to ask permission and setup location manager.
- If it’s denied or restricted, use your custom alert view for directing your user to your app’s settings page. (Reminder : you app will be restarted, before authorisation status is changed.)
- If your app is authorized, just setup location manager.
For going application’s setting page under iOS Settings section:
Camera & Microphone permission
For managing camera and microphone permission, you should import AVFoundation framework, use authorizationStatusForMediaType(AVMediaType) to check your app’s permission status and use requestAccessForMediaType function to grant access from users and if it’s not granted, you can direct your users to app’s settings page to request this permission.
You can download and explore sample project here!
You can find detailed information about Info.plist keys from Apple’s documentation.