Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glassonion1/RxStoreKit
StoreKit library for RxSwift
https://github.com/glassonion1/RxStoreKit
functional ios observer reactivex rxswift skpaymentqueue storekit swift
Last synced: 2 days ago
JSON representation
StoreKit library for RxSwift
- Host: GitHub
- URL: https://github.com/glassonion1/RxStoreKit
- Owner: glassonion1
- License: mit
- Created: 2017-06-21T03:55:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-05T12:50:24.000Z (almost 4 years ago)
- Last Synced: 2024-11-08T04:23:26.827Z (8 days ago)
- Topics: functional, ios, observer, reactivex, rxswift, skpaymentqueue, storekit, swift
- Language: Swift
- Size: 72.3 KB
- Stars: 112
- Watchers: 5
- Forks: 33
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rxswift - RxStoreKit - App Purchases). (Libraries)
README
# RxStoreKit
RxStoreKit is lightweight and easy to use Rx support for StoreKit(In-App Purchases).
## Usage
### Request Products
```swift
import StoreKit
import RxSwift
import RxStoreKitlet 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
```swift
SKPaymentQueue.default().rx.restoreCompletedTransactions()
.subscribe(onNext: { queue in
// paymentQueueRestoreCompletedTransactionsFinished
print(queue)
}, onError: { error in
// restoreCompletedTransactionsFailedWithError
print(queue)
}).disposed(by: disposeBag)
```### Request payment
```swift
let productRequest = SKProductsRequest(productIdentifiers: Set(["xxx.xxx.xxx"]))
productRequest.rx.productsRequest
.flatMap { response -> Observable in
return Observable.from(response.products)
}
.flatMap { product -> Observable in
return SKPaymentQueue.default().rx.add(product: product)
}
.subscribe(onNext: { transaction in
print(transaction)
}).disposed(by: disposeBag)
productRequest.start()
```### Request receipt refresh
```swift
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
```swift
let productRequest = SKProductsRequest(productIdentifiers: Set(["xxx.xxx.xxx"]))
productRequest.rx.productsRequest
.flatMap { response -> Observable in
return Observable.from(response.products)
}
.flatMap { product -> Observable in
return SKPaymentQueue.default().rx.add(product: product)
}
.flatMap { transaction -> Observable 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.
```swift
import PackageDescriptionlet 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.