OGeek|极客世界-中国程序员成长平台

标题: ios - 移动和使用托管的 In App Purchase 托管内容 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 23:46
标题: ios - 移动和使用托管的 In App Purchase 托管内容

我知道我正在下载托管的应用内购买。 它将托管的 In App Purchase 内容下载到 Cache 目录,但由于我需要托管 In App Purchase 内容才能永久保存,我需要将其移动到 Documents 目录。

一旦它在那里,我就需要实际访问内容。

我正在使用

    NSURL *url = download.contentURL;
    NSError *error = nil;
    NSArray *properties = [NSArray arrayWithObjects: NSURLLocalizedNameKey,
                           NSURLCreationDateKey, NSURLLocalizedTypeDescriptionKey, nil];

    NSArray *zipContentsArray = [[NSFileManager defaultManager]
                      contentsOfDirectoryAtURL:url
                      includingPropertiesForKeys:properties
                      optionsNSDirectoryEnumerationSkipsHiddenFiles)
                      error:&error];

显示缓存中的输出

The download's contentURL is
file:///private/var/mobile/Applications/**/Library/Caches/***.zip/

zipContentsArray = (
    "file:///private/var/mobile/Applications/***/Library/Caches/***.zip/ContentInfo.plist",
    "file:///private/var/mobile/Applications/***/Library/Caches/***.zip/Contents/",
    "file:///private/var/mobile/Applications/**/Library/Caches/***.zip/META-INF/"
)

我将如何访问内容(即使是在 Caches 文件夹中 - 我假设无论其位置如何,这都是相同的过程)?

令人抓狂的是,Apple 提供的有关整个过程的文档很少,因此我们会非常欢迎任何帮助。



Best Answer-推荐答案


我目前也遇到了同样的问题,但我也许可以让您更进一步。您有权将您的内容从缓存中移出,这在 Apple IAP 指南中有说明。 我正在尝试下载非消耗性 IAP 的内容并将其内容移动到正确的路径。 我已经设法将下载的内容放到 iphone 缓存中,但现在需要将此内容传递到正确的路径。

我使用了 http://xinsight.ca/blog/iap-content-download-in-ios6/ 中的一些代码这似乎是我需要的;但是我不确定我需要为我的应用程序包声明哪条路径。从代码来看,这似乎与'MyConfig'有关

- (void) processDownloadSKDownload*)download;
{
// convert url to string, suitable for NSFileManager
NSString *path = [download.contentURL path];

// files are in Contents directory
path = [path stringByAppendingPathComponent"Contents"];

NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSArray *files = [fileManager contentsOfDirectoryAtPath:path error:&error];
NSString *dir = [MyConfig downloadableContentPathForProductId:download.contentIdentifier]; // not written yet

for (NSString *file in files) {
    NSString *fullPathSrc = [path stringByAppendingPathComponent:file];
    NSString *fullPathDst = [dir stringByAppendingPathComponent:file];

    // not allowed to overwrite files - remove destination file
    [fileManager removeItemAtPath:fullPathDst error:NULL];

    if ([fileManager moveItemAtPath:fullPathSrc toPath:fullPathDst error:&error] == NO) {
        NSLog(@"Error: unable to move item: %@", error);
    }
}

有人可以对此进行补充,以便我们都能取得一些进展吗?

关于ios - 移动和使用托管的 In App Purchase 托管内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24646389/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4