Skip to content

guvera-labs/IAPurchaseManager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

IAPurchaseManager

Swift In-App Purchase Manager for iOS

Easy-to-use a singleton class that supports non-renewable in-app purchases. It's super cool because

  1. it's written in Swift
  2. it uses blocks!

Setup

Just drag IAPManager.swift to your project.

Making a purchase

If you want to make a purchase, all you need to do is to call a method:

  IAPManager.sharedManager.purchaseProductWithId(productId) { (error) -> Void in 
    if error == nil {
      // successful purchase!
    } else {
      // something wrong.. 
    }
}

You can call purchaseProductWithId without first loading products info because inside purchaseProductWithId it'll load it if needed. So just call purchaseProductWithId whenever you want to make a purchase.

But if you need to get all products info, you can load it by calling:

  IAPManager.sharedManager.loadProductsWithIds(productIds) { (error) -> Void in }

Restore transactions

To restore transactions call:

  IAPManager.sharedManager.restoreCompletedTransactions { (error) -> Void in }

Details

All completed transactions are saved to a file: ```swift data.writeToFile(purchasedItemsFilePath(), options: .AtomicWrite | .DataWritingFileProtectionComplete, error: &error) ```

If you want to add validation, keychain support or some other features, feel free to send me pull requests!

About

Swift In-App Purchase Manager for iOS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%