当您购买成功时,您将获得交易对象。不是吗?
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
遍历每个事务对象并使用以下代码:
if (transaction.downloads)
{
[[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];
}
成功下载后,您将收到一个委托呼叫:
-(void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads
{
for (SKDownload *download in downloads)
{
switch (download.downloadState) {
case SKDownloadStateActive:
NSLog(@"Download progress = %f and Download time: %f", download.progress, download.timeRemaining);
break;
case SKDownloadStateFinished:
NSLog(@"%@",download.contentURL);
// Download is complete. Content file URL is at
// path referenced by download.contentURL. Move
// it somewhere safe, unpack it and give the user
// access to it
break;
default:
break;
}
}
}
下载后,您将获得下载数据的 URL,现在您可以将其存储在库的应用程序支持文件夹中,并防止其自动同步到云端(如果需要)。而已。