How can you request photo gallery permissions in iOS a second time

☆樱花仙子☆ 提交于 2019-12-17 20:26:45

问题


In my iOS app I am accessing the user's photo gallery. The first time the user does this, it asks them for permission. Some of my users have reported getting a crash this first time due to the permission request, but it works fine on subsequent tries.

To be able to test this on my own, I need to be able remove the permission from my iPad and have it prompt again. Is there a way to do this either through the iPad/iPhone itself or through code?


回答1:


Run the Settings app. Go to General, then Reset. Tap on Reset Location & Privacy. This will reset all of your location and privacy settings, not just for your test app. But you are doing this on a development device so that should be OK. This works in the Simulator too.




回答2:


In iOS 7+, you can go into Settings > Privacy > Photos and explicitly enable or disable access for individual apps.

This is much better than resetting your entire device privacy settings!




回答3:


Another way is to temporary change Bundle Identifier (CFBundleIdentifier) in Info.plist. System will treat such app as a new separate app and will display "would like to access your Photos" alert. Don't forget to revert CFBundleIdentifier after you end testing.



来源:https://stackoverflow.com/questions/12916721/how-can-you-request-photo-gallery-permissions-in-ios-a-second-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!