Ios 应用程序传输安全性(如果我没有’;我不知道我需要使用的所有不安全的域

Ios 应用程序传输安全性(如果我没有’;我不知道我需要使用的所有不安全的域,ios,objective-c,app-transport-security,Ios,Objective C,App Transport Security,我看到这个问题得到了一些回答,但在我的例子中,我使用NSURLSession来显示图像。这些图像由用户上传或使用脚本扫描到数据库中 在这种情况下,编写异常URL(NSExceptionDomains)将不起作用,因为映像由用户在其站点或其他站点上托管。如果我允许NSAllowsArbitraryLoads,我是否仍然能够获得AppStore的批准,因为我没有实施ATS的最佳实践 我不知道最好的办法是什么。任何意见都将不胜感激 这是我正在使用的代码 NSString *thumbnail_

我看到这个问题得到了一些回答,但在我的例子中,我使用NSURLSession来显示图像。这些图像由用户上传或使用脚本扫描到数据库中

在这种情况下,编写异常URL(NSExceptionDomains)将不起作用,因为映像由用户在其站点或其他站点上托管。如果我允许NSAllowsArbitraryLoads,我是否仍然能够获得AppStore的批准,因为我没有实施ATS的最佳实践

我不知道最好的办法是什么。任何意见都将不胜感激

这是我正在使用的代码

    NSString *thumbnail_url = [tempObject objectForKey:@"image"];
    NSURL  *url = [NSURL URLWithString:thumbnail_url];
    NSURLSession *session = [NSURLSession sharedSession];

    NSURLSessionDownloadTask *downloadPhotoTask = [session downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
            NSData *imageData = [[NSData alloc] initWithContentsOfURL:location];
            dispatch_async(dispatch_get_main_queue(), ^{
                cell.tableImageView.image = [UIImage imageWithData:imageData];
        });
    }];

    [downloadPhotoTask resume];

是的,即使使用此参数,您也可以通过审核。
自iOS9 SDK以来,我们上传了许多版本,其中
NSAllowsArbitraryLoads
设置为
YES

备注:您的代码最好如下所示:

cell.thumbnailURL = URL;
__weak typeof(cell) weak
NSURLSessionDownloadTask *downloadPhotoTask = [session downloadTaskWithURL:URL completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
    NSData *imageData = [[NSData alloc] initWithContentsOfURL:location];
    UIImage *image = [UIImage imageWithData:imageData];
    dispatch_async(dispatch_get_main_queue(), ^{
        if (weakCell.thumbnailURL != URL) {
            return;
        }
        weakCell.tableImageView.image = image;
    });
}];
[downloadPhotoTask resume];

NSAllowsArbitraryLoads
是完全正确的,因此,您可以将应用程序提交到AppStore。