iOS停止向用户询问照片库权限 [英] iOS stopped asking user for Photo Library Permission

查看:99
本文介绍了iOS停止向用户询问照片库权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS不再要求用户提供照片库权限了。即使我从设备中删除了该应用。这也发生在模拟器上。

iOS is not asking user for Photo Library Permission anymore. Even when I deleted the app from the device. This also happens on Simulator.

switch ([ALAssetsLibrary authorizationStatus])
{
    case ALAuthorizationStatusAuthorized:
        RPMLog(@"authorized");
        break;
    case ALAuthorizationStatusDenied:
        RPMLog(@"denied");
        break;
    case ALAuthorizationStatusNotDetermined:
        RPMLog(@"not determined");
        break;
    case ALAuthorizationStatusRestricted:
        RPMLog(@"restricted");
        break;
}

我第一次安装应用程序时已经获得授权。在此之前,没有其他事件或屏幕要求照片触发用户提示。

I'm already authorized when I install the app for the first time. Prior to this, there's no other event or screen that asks for the photos to trigger the user prompt.

然后我在SavedPhotos中请求numberOfAssets并在没有访问提示的情况下获取它:

Then I request the numberOfAssets in SavedPhotos and get it without the access prompt:

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {

    if (!group) return;

    UIActionSheet *actionSheet = nil;
    if (([group numberOfAssets] > 0))
    {
        actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(@"Take new photo", nil), NSLocalizedString(@"Use last photo taken", nil), NSLocalizedString(@"Choose existing", nil), nil];
    }
    else
    {
        actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(@"Take new photo", nil), NSLocalizedString(@"Choose existing", nil), nil];
    }

    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    [actionSheet showFromTabBar:self.tabBar];
    [TestFlight passCheckpoint:@"New Look: Tab Bar"];

} failureBlock:^(NSError *error) {

    NSAssert(!error, [error description]);
}];


推荐答案

正在发生的事情是iOS正在保存授予的权限您的应用程序映射到软件包ID,如果删除该应用程序,此数据会持续24小时,这样可以避免在用户重新安装应用程序时重新提示用户(可能是在错误地删除应用程序后)。

What is happening is iOS is saving the permission granted to your app mapped to the bundle ID, if the app is deleted this data persists for 24 hours, this avoids re prompting the user if they reinstall the app (perhaps after mistakingly deleting an app).

这也适用于推送通知提示。

This also happens for Push Notification prompts.

作为一种解决方法,我引用苹果推送通知:

As a workaround, I quote Apple concerning the Push Notifications:


重置iOS上的推送通知权限提醒

第一个
时间a支持推送的应用程序注册表用于推送通知,iOS询问
用户是否希望接收该应用程序的通知。一旦用户
响应此警报,除非
设备已恢复或应用程序已卸载至少一天,否则不会再次显示该消息。

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

如果您想模拟首次运行的应用,可以将
的应用程序卸载一天。 你可以通过设置一天的系统时钟或者更多的
来实现后者而不需要
实际等待一天,完全关闭设备,然后将设备恢复为

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on.

来源: Apple技术说明TN2265

这篇关于iOS停止向用户询问照片库权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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