我正在嘗試將應用內購買功能添加到我的應用程序中,並且我想下載託管在我自己的服務器中的內容。 RMStore提供了一個API來做到這一點,但我無法弄清楚如何做到這一點。如何將自我託管的內容與交易相關聯?
文件說:
RMStore代表通過 可選
contentDownloader
代表的自託管內容的下載。您可以使用RMStoreContentDownloader
協議提供自己的 實現:
- (void)downloadContentForTransaction:(SKPaymentTransaction*)transaction
success:(void (^)())successBlock
progress:(void (^)(float progress))progressBlock
failure:(void (^)(NSError *error))failureBlock;
呼叫
successBlock
如果下載成功,failureBlock
如果 是不是和progressBlock
通知下載進度。 RMStore將 認爲交易已完成或僅在 內容下載程序代理已成功或未成功下載其內容 後失敗。
這裏是協議(從RMStore.h):
@protocol RMStoreContentDownloader <NSObject>
/**
Downloads the self-hosted content associated to the given transaction and calls the given success or failure block accordingly. Can also call the given progress block to notify progress.
@param transaction The transaction whose associated content will be downloaded.
@param successBlock Called if the download was successful. Must be called in the main queue.
@param progressBlock Called to notify progress. Provides a number between 0.0 and 1.0, inclusive, where 0.0 means no data has been downloaded and 1.0 means all the data has been downloaded. Must be called in the main queue.
@param failureBlock Called if the download failed. Must be called in the main queue.
@discussion Hosted content from Apple’s server (@c SKDownload) is handled automatically by RMStore.
*/
- (void)downloadContentForTransaction:(SKPaymentTransaction*)transaction
success:(void (^)())successBlock
progress:(void (^)(float progress))progressBlock
failure:(void (^)(NSError *error))failureBlock;
@end
只需將它說,下載相關的特定交易自託管的內容。我如何將自託管與交易相關聯?
您的答案不提供將自託管內容與交易關聯的任何解決方案。 – guneykayim 2015-12-18 11:08:44
我只是更新我的答案:'productIdentifier'在'SKPaymentTransaction'裏面! – Zanzi 2015-12-18 11:48:11
如何啓動下載?例如,這是我的下載鏈接http://stackoverflow.com/users/flair/1249328.png在哪裏以及如何開始下載過程並將其與交易相關聯? – guneykayim 2015-12-18 11:53:39