iosin-app-purchasermstore

How to use downloadContentForTransaction: success: progress: failure: in RMStore


I'm trying to use this method from RMStore

- (void)downloadContentForTransaction:(SKPaymentTransaction*)transaction
                              success:(void (^)())successBlock
                             progress:(void (^)(float progress))progressBlock
                              failure:(void (^)(NSError *error))failureBlock;

but I don't understand how to use it. Can anyone show me an example?

Update:

When I select method from autocomplete list, it don't create blocks automatically enter image description here like usual: When I try to open it manually I got errors


Solution

  • From the RMStore readme:

    RMStore delegates the downloading of self-hosted content via the optional contentDownloader delegate. You can provide your own implementation using the RMStoreContentDownloader protocol.

    In short, downloadContentForTransaction:success:progress:failure: is part of a protocol you need to implement, not call.

    I should add that if you're using Apple hosted content, RMStore will take care of it automatically. Again, from the readme:

    Downloadable content hosted by Apple (SKDownload) will be automatically downloaded when purchasing o restoring a product. RMStore will notify observers of the download progress by calling storeDownloadUpdate: and finally storeDownloadFinished:. Additionally, RMStore notifies when downloads are paused, cancelled or have failed.

    RMStore will notify that a transaction finished or failed only after all of its downloads have been processed. If you use blocks, they will called afterwards as well. The same applies to restoring transactions.