Coder Social home page Coder Social logo

rxstorekit's Introduction

RxStoreKit

RxStoreKit is lightweight and easy to use Rx support for StoreKit(In-App Purchases).

Usage

Request Products

import StoreKit
import RxSwift
import RxStoreKit

let disposeBag = DisposeBag()

let productRequest = SKProductsRequest(productIdentifiers: Set(["your app product id"]))
productRequest.rx.productsRequest
    .subscribe(onNext: { product in
        print(product)
    }).disposed(by: disposeBag)
productRequest.start()

Restore Transactions

SKPaymentQueue.default().rx.restoreCompletedTransactions()
    .subscribe(onNext: { queue in
        // paymentQueueRestoreCompletedTransactionsFinished
        print(queue)
    }, onError: { error in
        // restoreCompletedTransactionsFailedWithError
        print(queue)
    }).disposed(by: disposeBag)

Request payment

let productRequest = SKProductsRequest(productIdentifiers: Set(["xxx.xxx.xxx"]))
productRequest.rx.productsRequest
    .flatMap { response -> Observable<SKProduct> in
        return Observable.from(response.products)
    }
    .flatMap { product -> Observable<SKPaymentTransaction> in
        return SKPaymentQueue.default().rx.add(product: product)
    }
    .subscribe(onNext: { transaction in
        print(transaction)
    }).disposed(by: disposeBag)
productRequest.start()

Request receipt refresh

let receiptRefreshRequest = SKReceiptRefreshRequest()
receiptRefreshRequest.rx.request
    .subscribe(onCompleted: {
        // Refreshed receipt is available
    }, onError: { error in
        print(error)
    }).disposed(by: disposeBag)
receiptRefreshRequest.start()

Download hosting contents

Download In-App Purchase Contents

let productRequest = SKProductsRequest(productIdentifiers: Set(["xxx.xxx.xxx"]))
productRequest.rx.productsRequest
    .flatMap { response -> Observable<SKProduct> in
        return Observable.from(response.products)
    }
    .flatMap { product -> Observable<SKPaymentTransaction> in
        return SKPaymentQueue.default().rx.add(product: product)
    }
    .flatMap { transaction -> Observable<SKDownload> in
        return SKPaymentQueue.default().rx.start(downloads: transaction.downloads)
    }
    .subscribe(onNext: { download in
        print(download)
    }).disposed(by: disposeBag)
productRequest.start()

Installation

This library depends on both RxSwift and RxCocoa

Swift Package Manager

Create a Package.swift file.

import PackageDescription

let package = Package(
  name: "RxTestProject",
  dependencies: [
    .package(url: "https://github.com/glassonion1/RxStoreKit.git", from: "1.3.0")
  ],
  targets: [
    .target(name: "RxTestProject", dependencies: ["RxStoreKit"])
  ]
)

License

RxStoreKit is available under the MIT license. See the LICENSE file for more info.

rxstorekit's People

Contributors

bigmotor avatar frboulais avatar glassonion1 avatar joaoffcosta avatar jondwillis avatar k-4-b-4 avatar tiago-queiros avatar zigdanis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rxstorekit's Issues

CocoaPods Version 1.2.3

This repo hasn't tagged new releases for 1.2.3 and 1.2.2 version. Latest version accessible from CocoaPods without targeting a branch is showing 1.2.1 which is not up to date with RxSwift and RxCocoa dependencies.

3 errors occurred in pod spec lint

-> RxStoreKit (1.2.0)
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.
- ERROR | xcodebuild: RxStoreKit/Sources/SKReceiptRefreshRequestDelegateProxy.swift:38:29: error: value of optional type '((SKRequest) -> Void)?' not unwrapped; did you mean to use '!' or '?'?
- ERROR | xcodebuild: RxStoreKit/Sources/SKReceiptRefreshRequestDelegateProxy.swift:43:29: error: value of optional type '((SKRequest, Error) -> Void)?' not unwrapped; did you mean to use '!' or '?'?

Analyzed 1 podspec.

Finish transaction after it was validated on own server

Is it possible to defer finishing transactions until they were verified on our own server?
I'm using consumable products and user can possibly fail to upload purchase receipt to our own server for validating it. So next time this purchase won't be available to proceed, because it was already marked as finished.

Support iOS 9.0

Hi! Thanks for the Rx wrapper around StoreKit👍
It looks like you don't use iOS 10 specific APIs. Can you lower minimum iOS version to 9.0?

CocoaPods support

In the latest release, there is no podspec file, so it is not accessible through CocoaPods.

Are you planning to support CocoaPods or is it SPM only from now on?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.