Latest 1.0
Homepage https://github.com/suvov/VSStoreKit
License MIT
Platforms ios 8.0
Authors

Build Status codecov.io Version License Platform

Icon

VSStoreKit is an easy to use library that you can use to make in-app purchases in your iOS app.

Requirements

  • Swift 3.0
  • Xcode 8
  • iOS 8.0+

Installation

CocoaPods (recommended)

use_frameworks!

pod 'VSStoreKit'

Documentation

Read the docs. Generated with jazzy. Hosted by GitHub Pages.

Generate

$ ./build_docs.sh

Preview

$ open index.html -a Safari

Getting Started

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

// 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, [email protected]

License

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

Latest podspec

{
    "name": "VSStoreKit",
    "version": "1.0",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "summary": "Simple iOS StoreKit library",
    "description": "You can use VSStoreKit to make in-app purchases in iOS app.",
    "homepage": "https://github.com/suvov/VSStoreKit",
    "authors": {
        "Vladimir Shutyuk": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/suvov/VSStoreKit.git",
        "tag": "1.0"
    },
    "source_files": "VSStoreKit/*.swift",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This