RCPurchasesDelegate

@protocol RCPurchasesDelegate <NSObject>

Delegate for RCPurchases responsible for handling updating your app’s state in response to completed purchases.

Note

Delegate methods can be called at any time after the delegate is set, not just in response to makePurchase: calls. Ensure your app is capable of handling completed transactions anytime delegate is set.
  • Called when a transaction has been succesfully posted to the backend. This will be called in response to makePurchase: call but can also occur when a subscription renews.

    Declaration

    Objective-C

    - (void)purchases:(nonnull RCPurchases *)purchases
        completedTransaction:(nonnull SKPaymentTransaction *)transaction
             withUpdatedInfo:(nonnull RCPurchaserInfo *)purchaserInfo;

    Swift

    func purchases(_ purchases: RCPurchases, completedTransaction transaction: SKPaymentTransaction, withUpdatedInfo purchaserInfo: RCPurchaserInfo)

    Parameters

    purchases

    Related RCPurchases object

    transaction

    The transaction that was approved by StoreKit and verified by the backend

    purchaserInfo

    The updated purchaser info returned from the backend. The new transaction may have had an effect on expiration dates and purchased products. Use this object to up-date your app state.

  • Called when a transaction fails to complete a purchase with StoreKit or fails to be posted to the backend. The localizedDescription of failureReason will contain a message that may be useful for displaying to the user. Be sure to dismiss any purchasing UI if this method is called. This method can also be called at any time but outside of a purchasing context there often isn’t much to do.

    Declaration

    Objective-C

    - (void)purchases:(nonnull RCPurchases *)purchases
        failedTransaction:(nonnull SKPaymentTransaction *)transaction
               withReason:(nonnull NSError *)failureReason;

    Swift

    func purchases(_ purchases: RCPurchases, failedTransaction transaction: SKPaymentTransaction, withReason failureReason: Error)

    Parameters

    purchases

    Related RCPurchases object

    transaction

    The transaction that failed to complete

    failureReason

    NSError containing the reason for the failure

  • Called whenever RCPurchases receives an updated purchaser info outside of a purchase. This will happen periodically throughout the life of the app (e.g. UIApplicationDidBecomeActive).

    Declaration

    Objective-C

    - (void)purchases:(nonnull RCPurchases *)purchases
        receivedUpdatedPurchaserInfo:(nonnull RCPurchaserInfo *)purchaserInfo;

    Swift

    func purchases(_ purchases: RCPurchases, receivedUpdatedPurchaserInfo purchaserInfo: RCPurchaserInfo)

    Parameters

    purchases

    Related RCPurchases object

    purchaserInfo

    Updated RCPurchaserInfo

  • Called when restoring transactions has been completed successfully.

    Declaration

    Objective-C

    - (void)purchases:(nonnull RCPurchases *)purchases
        restoredTransactionsWithPurchaserInfo:
            (nonnull RCPurchaserInfo *)purchaserInfo;

    Swift

    func purchases(_ purchases: RCPurchases, restoredTransactionsWith purchaserInfo: RCPurchaserInfo)

    Parameters

    purchases

    Related RCPurchases object

    purchaserInfo

    Updated RCPurchaserInfo

  • Called when restoring transactions has failed

    Declaration

    Objective-C

    - (void)purchases:(nonnull RCPurchases *)purchases
        failedToRestoreTransactionsWithError:(nonnull NSError *)error;

    Swift

    func purchases(_ purchases: RCPurchases, failedToRestoreTransactionsWithError error: Error)

    Parameters

    purchases

    Related RCPurchases object

    error

    The failure reason

  • Called whenever RCPurchases fails to fetch a purchaserInfo.

    Declaration

    Objective-C

    - (void)purchases:(nonnull RCPurchases *)purchases
        failedToUpdatePurchaserInfoWithError:(nonnull NSError *)error;

    Swift

    func purchases(_ purchases: RCPurchases, failedToUpdatePurchaserInfoWithError error: Error)
  • Called when a user initiates a promotional in-app purchase from the App Store. Use this method to tell RCPurchases if your app is able to handle a purchase at the current time. If yes, return true and RCPurchases will initiate a purchase and will finish with one of the appropriate RCPurchasesDelegate methods. If the app is not in a state to make a purchase: cache the defermentBlock, return no, then call the defermentBlock when the app is ready to make the promotional purchase. If the purchase should never be made, do not cache the defermentBlock and return NO. The default return value is NO, if you don’t override this delegate method, RCPurchases will not proceed with promotional purchases.

    Declaration

    Objective-C

    - (BOOL)purchases:(nonnull RCPurchases *)purchases
        shouldPurchasePromoProduct:(nonnull SKProduct *)product
                    defermentBlock:(nonnull RCDeferredPromotionalPurchaseBlock)
                                       makeDeferredPurchase;

    Swift

    optional func purchases(_ purchases: RCPurchases, shouldPurchasePromoProduct product: SKProduct, defermentBlock makeDeferredPurchase: @escaping RCDeferredPromotionalPurchaseBlock) -> Bool

    Parameters

    product

    SKProduct the product that was selected from the app store