OnDemandResource和新版App

时间:2017-06-04 09:03:51

标签: ios objective-c iphone xcode on-demand-resources

我遇到了OnDemandResource

的问题

1)我从TestFlight下载旧版App ... App下载OnDemandResource,一切正常。

2)我上传了一个新版App,我在其中添加了新资源,并将其安装为旧版本的更新。当新版本App运行时,不下载新的OnDemandResource,App认为所有资源都已下载。

如何解决?

首先启动旧版本:

NSSet *tags = [NSSet setWithObjects: @"PACK_1", @"PACK_2", nil];
NSBundleResourceRequest *resourceRequest = [[NSBundleResourceRequest alloc] initWithTags:tags];
resourceRequest.loadingPriority = 1.0;
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:^(BOOL resourcesAvailable) {
    if (resourcesAvailable) {
    } else {

        // Download PACK_1 and PACK_2

        [resourceRequest beginAccessingResourcesWithCompletionHandler:^(NSError * __nullable error) {
            if(!error){
            } else {

                // Run App
            }
        }];
    }
}];

首先启动新版本(更新旧版本,添加新PACK_3):

NSSet *tags = [NSSet setWithObjects: @"PACK_1", @"PACK_2", @"PACK_3", nil];
NSBundleResourceRequest *resourceRequest = [[NSBundleResourceRequest alloc] initWithTags:tags];
resourceRequest.loadingPriority = 1.0;
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:^(BOOL resourcesAvailable) {

    // Check PACK_1, PACK_2 and PACK_3 and resourcesAvailable = true, but PACK_3 not download

    if (resourcesAvailable) {

        // Run App

    } else {

        // Will not start to download PACK_3

        [resourceRequest beginAccessingResourcesWithCompletionHandler:^(NSError * __nullable error) {
            if(!error){
            } else {
            }
        }];
    }
}];

0 个答案:

没有答案