菜鸟教程小白 发表于 2022-12-12 23:46:01

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


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

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

<p>我正在使用</p>

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

    NSArray *zipContentsArray = [
                      contentsOfDirectoryAtURL:url
                      includingPropertiesForKeys:properties
                      options:(NSDirectoryEnumerationSkipsHiddenFiles)
                      error:&amp;error];
</code></pre>

<p>显示缓存中的输出</p>

<pre><code>The download&#39;s contentURL is
file:///private/var/mobile/Applications/**/Library/Caches/***.zip/

zipContentsArray = (
    &#34;file:///private/var/mobile/Applications/***/Library/Caches/***.zip/ContentInfo.plist&#34;,
    &#34;file:///private/var/mobile/Applications/***/Library/Caches/***.zip/Contents/&#34;,
    &#34;file:///private/var/mobile/Applications/**/Library/Caches/***.zip/META-INF/&#34;
)
</code></pre>

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

<p>令人抓狂的是,Apple 提供的有关整个过程的文档很少,因此我们会非常欢迎任何帮助。 </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我目前也遇到了同样的问题,但我也许可以让您更进一步。您有权将您的内容从缓存中移出,这在 Apple IAP 指南中有说明。
我正在尝试下载非消耗性 IAP 的内容并将其内容移动到正确的路径。
我已经设法将下载的内容放到 iphone 缓存中,但现在需要将此内容传递到正确的路径。</p>

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

<pre><code>- (void) processDownload:(SKDownload*)download;
{
// convert url to string, suitable for NSFileManager
NSString *path = ;

// files are in Contents directory
path = ;

NSFileManager *fileManager = ;
NSError *error = nil;
NSArray *files = ;
NSString *dir = ; // not written yet

for (NSString *file in files) {
    NSString *fullPathSrc = ;
    NSString *fullPathDst = ;

    // not allowed to overwrite files - remove destination file
    ;

    if ( == NO) {
      NSLog(@&#34;Error: unable to move item: %@&#34;, error);
    }
}
</code></pre>

<p>有人可以对此进行补充,以便我们都能取得一些进展吗?</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 移动和使用托管的 In App Purchase 托管内容,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/24646389/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/24646389/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 移动和使用托管的 In App Purchase 托管内容