目标C语言 iOS停止要求用户的照片库权限



iOS不再要求用户获得照片库权限。即使我从设备上删除了应用程序。

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

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

然后我请求numberOfAssets在SavedPhotos和得到它没有访问提示:

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]);
}];

这个问题是关于Photo Library权限的,有其他方法可以不改变系统时钟和关闭设备。

你可以直接去"设置"app

(General> Reset> Reset Location &隐私)。

这将使应用程序再次要求照片库,位置和其他权限。

发生的事情是iOS将授予应用的权限保存到映射到bundle ID,如果应用被删除,该数据将持续24小时,这避免了重新提示用户重新安装应用(可能在错误地删除应用后)。

这也发生在推送通知提示符。

作为一个变通方法,我引用苹果关于推送通知:

重置iOS推送通知权限警报

第一当启用推送功能的应用注册推送通知时,iOS会询问用户是否希望收到该应用程序的通知。一旦用户已响应此警报,它不会再次出现,除非设备已恢复或应用已卸载至少一天

如果你想模拟应用程序的第一次运行,你可以离开这款应用被卸载了一天。可以实现后一种实际上等待一天通过设置系统时钟向前一天或更多,完全关闭设备,然后再打开设备

来源:Apple Technical Note TN2265

通过设置应用程序进行设置很难实现自动化。我们使用simctl以自动方式重置模拟器内容和设置,以重置权限对话框。这需要在模拟器中重新安装应用程序,但simctl可以完成此操作。

您可以通过两种方式检查此权限

  • 模拟器
    您可以执行模拟器/重置内容和设置
  • 在物理设备(iPhone, iPad)
    您可以更改日期,至少相差24小时。

但是首先从设备上卸载应用程序,然后重新启动,然后应用这个东西,然后它将工作

如果你正在使用iOS模拟器,使用模拟器/重置内容和设置来重置它…似乎重置了此设置。当然,你需要重新安装你的应用。

您只需要遵循下面的点,无需重新安装或删除应用程序。

  • App从后台删除
  • 进入设置->常规->重置->点击重置位置&隐私

希望你有帮助。

最新更新