Skip to content

marcbaldwin/RxStoreKit

Repository files navigation

RxStoreKit

RxSwift wrapper for StoreKit.

Fetch products

SKProduct.fetch(["my.product.id", "my.other.product.id"])
    .subscribe(
      onNext: { products: [SKProduct] in
        // display products
      },
      onError: { error in
        // handle the error
      }
    )
    .disposed(by: disposeBag)

Observe the payment queue

SKPaymentQueue.default().rx.transactionsUpdated
    .subscribe(onNext: { transactions: [SKPaymentTransaction] in
        // Unlock content?
    })
    .disposed(by: disposeBag)

Observe restore completed transactions

SKPaymentQueue.default().rx.restoreCompletedTransactions()
    .subscribe(
      onNext: { transactions: [SKPaymentTransaction] in
        // Unlock content?
      },
      onError: { error in
        // handle the error
      }
    )
    .disposed(by: disposeBag)

Verify receipts

let receiptValidator = ReceiptValidator(secret: "my_secret_key")
receiptValidator.verifySubscription(productIds: ["my.product.id"])
    .subscribe(
      onNext: { receipt in
        // check expiry date of receipt
      },
      onError: { error in
        // handle the error
      }
    )
    .disposed(by: disposeBag)

About

RxSwift wrapper for StoreKit.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors