Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How to ask for permission? (Location, Camera, Calendar, etc.)

Hey Amit Bijlani Ben Jakuben Holger Liesegang ,

How does one ask the user for permission to access certain functionalities, such as location, camera etc.?

Or is this integrated and asked by Apple automatically?

Thanks a lot! :)

Cheers, pascal

2 Answers

Hi Pascal Hausberger !

Stone Preston is absolutely right and I'd just like to add a recommendation for tools like ClusterPrePermissions:

"Cluster's reusable pre-permissions utility lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request."

But why use Pre-Permissions?

"On iOS, when your code tries to access the Camera Roll or the Address Book, the system automatically shows an alert to the user.

If the user says "Don't Allow" to this alert, you have burned your one-and-only chance to get that access. The user will have to jump through a 5-step process outside of your app to re-enable access, which they will rarely, if ever, do.

Often the user wasn't even expecting the access alert, and by habit will tap "Don't Allow". This is a lose-lose scenario for both you and your user."

Wow thanks so much for the tip!!!!! :)

in my experience it asks automatically. so if your app uses an image picker, the first time that image picker shows up an alert view will pop up that says something like "allow [your app name] access to your photos?" and they select yes or no, if they select yes it wont appear again, if they select no it will cancel the image picker. Same for anything else that can be changd in privacy settings like location and what not. Whenever a location manager starts looking for the first time an alert view comes up and asks for permission.

Im not sure what happens if the user changes privacy settings while your app is running though, that might be a different story

Thanks Preston! :)