Advanced Permission Management for iOS Applications

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.

Location

First, you should add your usage descriptions for tracking location,  either one of always or when-in-use situation or both.

  • NSLocationWhenInUseUsageDescription
  • NSLocationAlwaysUsageDescription

screen-shot-2016-09-25-at-11-30-59

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.

screen-shot-2016-09-25-at-11-54-27

For going application’s setting page under iOS Settings section:

screen-shot-2016-09-25-at-11-55-05

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.

Camera

Screen Shot 2016-09-25 at 12.48.13.png

Microphone

screen-shot-2016-09-25-at-12-44-46

You can download and explore sample project here!

You can find detailed information about Info.plist keys from Apple’s documentation.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s