https://github.com/suvov/vsstorekit
Simple iOS StoreKit library
https://github.com/suvov/vsstorekit
in-app in-app-purchase ios storekit swift
Last synced: 8 months ago
JSON representation
Simple iOS StoreKit library
- Host: GitHub
- URL: https://github.com/suvov/vsstorekit
- Owner: suvov
- License: mit
- Created: 2017-07-03T09:36:12.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-08-19T04:02:10.000Z (almost 4 years ago)
- Last Synced: 2025-10-23T09:55:42.310Z (8 months ago)
- Topics: in-app, in-app-purchase, ios, storekit, swift
- Language: Swift
- Homepage: http://suvov.github.io/VSStoreKit
- Size: 468 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VSStoreKit
[](https://travis-ci.org/suvov/VSStoreKit) [](https://codecov.io/gh/suvov/VSStoreKit/branch/master) [](http://cocoapods.org/pods/VSStoreKit) [](http://cocoapods.org/pods/VSStoreKit) [](http://cocoapods.org/pods/VSStoreKit)
![Icon][img0]
VSStoreKit is an easy to use library that you can use to make in-app purchases in your iOS app.
## Requirements
* Swift 5.0
* Xcode 10
* iOS 8.0+
## Installation
#### [CocoaPods](http://cocoapods.org) (recommended)
````ruby
use_frameworks!
pod 'VSStoreKit'
````
## Documentation
Read the [docs][docsLink]. Generated with [jazzy](https://github.com/realm/jazzy). Hosted by [GitHub Pages](https://pages.github.com).
#### Generate
````bash
$ ./build_docs.sh
````
#### Preview
````bash
$ open index.html -a Safari
````
## Getting Started
````swift
import VSStoreKit
````
## Design
This library has five primary components with the following responsibilities:
1. `StoreAccess` — requesting products from the Store, providing product details such as price and purchasing products
2. `PurchasedProductsProtocol` — instance conforming to this protocol stores completed purchases
3. `LocalProductsDataSource` — instance conforming to this protocol provides information about products for sale in the app
4. `ProductsDataSource` — also provides information about products for sale, but combines local and received from the Store information about products
5. `StoreAccessObserver` — observing StoreAccess state change and notifying client via callback methods
## Example
````swift
// 1. Create an instance conforming to PurchasedProductsProtocol
let puchasedProducts: PurchasedProductsProtocol = PurchasedProducts()
// 2. Provide StoreAccess purchaseCompletionHandler so it can mark products as purchased
let storeAccess = StoreAccess.shared
storeAccess.purchaseCompletionHandler = { purchasedProductIdentifier in
puchasedProducts.markProductAsPurchased(purchasedProductIdentifier)
}
// 3. Create an instance conforming to LocalProductsDataSource with your products (in-app purchases)
let localProducts: LocalProductsDataSource = LocalProducts()
// 4. Request products from the store
storeAccess.requestProductsWithIdentifiers(localProducts.productIdentifiers)
// 5. Instantiate ProductsDataSource object that you will use to populate your UITableView, UICollectionView or whatever with products (in-app purchases)
let productsDataSource = ProductsDataSource(localProducts: localProducts, storeProducts: storeAccess)
// 6. Buy product
let productIdentifier = productsDataSource.identifierForProductAtIndex(index)
storeAccess.purchaseProductWithIdentifier(productIdentifier)
// 7. Observe StoreAccess state change with help of StoreAccessObserver by providing it optional handlers for the states you are interested in
let storeAccessObserver = StoreAccessObserver()
storeAccessObserver.receivedProductsStateHandler = {
// reload your products presentation
}
storeAccessObserver.purchasedStateHandler = {
// reload your products presentation
}
````
## Author
Vladimir Shutyuk, vladimir.shutyuk@gmail.com
## License
VSStoreKit is available under the MIT license. See the LICENSE file for more info.
[img0]:https://raw.githubusercontent.com/suvov/VSStoreKit/master/Icon0.png
[docsLink]:https://suvov.github.io/VSStoreKit