• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 移动和使用托管的 In App Purchase 托管内容

[复制链接]
菜鸟教程小白 发表于 2022-12-12 23:46:01 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我知道我正在下载托管的应用内购买。 它将托管的 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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap