如何对选择“不允许”的用户作出反应当要求访问照片的权限? [英] How do I react to a user choosing "Don't Allow" when asking for permission to access Photos?

查看:101
本文介绍了如何对选择“不允许”的用户作出反应当要求访问照片的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,当他们点击不允许时,imagePicker没有显示给用户说明进入隐私设置并打开它的屏幕。

Basically, when they hit "Don't Allow", the imagePicker isn't showing the screen that gives the user the instructions to go into privacy settings and turn it on.

如果我杀死了应用程序并返回,那么隐私设置就在那里。所以我想我可能需要在触摸不允许时手动执行此操作。

If I kill the app and go back, the privacy setting is there. So I figured I probably need to manually do this when they touch "Don't Allow".

当用户允许或不允许访问时是否有回调到他们的照片库?我在文档中找不到。至少我可以忽略imageView。

Is there a callback for when a user allows or doesn't allow access to their photo library? I can't find it in the docs. At the very least I could dismiss the imageView.

谢谢!

推荐答案

如果这是用户第一次尝试从您的应用程序访问照片库,然后询问用户是否允许。如果用户选择不允许,那么在这一点上没有理由显示一条消息告诉他们去设置。

If this is the first time the user tries to access the photo library from your app then the user is asked whether it is allowed or not. If the user chooses "Don't Allow" then at that point there is no reason to show a message telling them to go to settings. They just made their decision.

通常您应该使用 ALAssetsLibrary authorizationStatus ,以便您可以正确更新您的UI无论用户在过去的任何选择。

As a rule you should use ALAssetsLibrary authorizationStatus so you can update your UI properly based on whatever choice the user made in the past.

但是,第一次将不确定。没有任何事件会告诉你用户何时做出选择。而且几乎不需要知道。如果用户选择不允许,他们只需关闭图像选择器。如果他们选择允许,那么他们选择一个图像。

But the 1st time it will be "not determined". There is no event that will tell you when the user actually makes their choice. And there is little need to know. If the user chooses "Don't Allow" they simply dismiss the image picker. If they choose "Allow" then they pick an image.

答案:
你唯一的选择是看看authorizationStatus是否返回ALAuthorizationStatusNotDetermined。如果是,请使用ALAssetsLibrary enumerateGroupsWithTypes:usingBlock:failureBlock:并等待结果。如果得到失败块,请再次检查authorizationStatus。如果现在是ALAuthorizationStatusDenied,那么你知道用户点击不允许。

Answer: The only option you have is to see if authorizationStatus returns ALAuthorizationStatusNotDetermined. If it does, use ALAssetsLibrary enumerateGroupsWithTypes:usingBlock:failureBlock: and wait for the result. If you get the failure block check the authorizationStatus again. If it is now ALAuthorizationStatusDenied then you know the user tapped "Don't Allow".

这篇关于如何对选择“不允许”的用户作出反应当要求访问照片的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆