PHPhotoLibrary请求授权,未请求 [英] PHPhotoLibrary requestAuthorization, not requesting

查看:488
本文介绍了PHPhotoLibrary请求授权,未请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了进行测试,我试图重新创建系统请求访问"弹出窗口体验.

For testing, I was trying to recreate the system 'Requesting Access' popup experience.

更新:
在iOS 11下,删除该应用后,系统弹出窗口将再次显示.

Update:
Under iOS 11, after deleting the App, the system popup will be displayed again.

(先前的问题)

第一次运行该应用程序(并且仅时间),系统弹出窗口显示,要求访问.此后,甚至不删除应用程序并重新启动设备将再次触发该弹出窗口.

First time the App run (and the only time), the system popup showed, requesting access. After that, not even deleting the App and restarting the device will trigger that popup again.

换句话说,设备记住"用户请求,无法重置它.

In other words, the device 'remembers' the user request and there's no way to reset it.

代码如下:

[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {

    switch (status) {
        case PHAuthorizationStatusAuthorized:
            NSLog(@"PHAuthorizationStatusAuthorized");
            break;

        case PHAuthorizationStatusDenied:
            NSLog(@"PHAuthorizationStatusDenied");
            break;
        case PHAuthorizationStatusNotDetermined:
            NSLog(@"PHAuthorizationStatusNotDetermined");
            break;
        case PHAuthorizationStatusRestricted:
            NSLog(@"PHAuthorizationStatusRestricted");
            break;
    }

}];

在设置中关闭访问权限后,它将继续打印"PHAuthorizationStatusDenied".但不显示任何弹出窗口.立即返回.

When access is off in settings, it keeps printing "PHAuthorizationStatusDenied". But does not present any popup. Returns immediately.

建议在"plist"中添加捆绑显示名称".尝试使用空值,$(PRODUCT_NAME)和不同的字符串无济于事.

It was suggested to add 'Bundle display name' to the plist. Tried it to no avail, with empty value, $(PRODUCT_NAME), and different strings.

清理项目,删除DrivedData(并每次从模拟器中删除App).没有运气.

Cleaned project, deleted DrivedData (and delete App from simulator every time). No luck.

更多信息:

一旦在设置"中关闭照片访问权限,Apple示例代码"SamplePhotosApp"就会崩溃.

The Apple sample code "SamplePhotosApp", is crashing once you turn off photo access in the Settings.

推荐答案

进一步阅读后,这似乎是设计使然.

After further reading, this seems to be by design.

来自Apple:

此方法总是立即返回.如果用户以前有 授予或拒绝照片库访问权限,它将执行 处理程序块在调用时;否则,它会显示警报并 仅在用户响应警报后才执行该块.

This method always returns immediately. If the user has previously granted or denied photo library access permission, it executes the handler block when called; otherwise, it displays an alert and executes the block only after the user has responded to the alert.

如果用户被提示一次,则说此方法总是立即返回".之后,它将不再显示请求.似乎无法(只能使用一些自定义消息)再次使用系统消息.

Saying 'This method always returns immediately' if user was prompt once. After that it will not show the request again. Seems to be no way (but some custom message) to use the system message again.

这篇关于PHPhotoLibrary请求授权,未请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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