Skip to content

An easy-to-use Swift library for In-App Purchases, using Iaptic for receipts validation

License

Notifications You must be signed in to change notification settings

iaptic/iaptic-swift

 
 

Repository files navigation

An easy-to-use Swift library for In-App Purchases, using Fovea.Billing for receipts validation.

Features

  • ✅ Purchase a product
  • ✅ Restore purchased products
  • ✅ Verify transactions with the App Store on Fovea.Billing server
  • ✅ Handle and notify payment transaction states
  • ✅ Retreive products information from the App Store
  • ✅ Support all product types (consumable, non-consumable, auto-renewable subscription, non-renewing subscription)
  • ✅ Status of purchases available when offline
  • ✅ Server integration with a Webhook

Basic Usage

This Swift Package is very quick to install and very easy to use. Let's see the basic usage and go to the documentation for more information.

  • Initialize the library
InAppPurchase.initialize(
    iapProducts: [ IAPProduct(productIdentifier: "my_product", productType: .nonConsumable) ],
    validatorUrlString: "https://validator.fovea.cc/v1/validate?appName=demo&apiKey=12345678"
)
  • Stop library when the application will terminate
InAppPurchase.stop()
  • Display product information
guard let product: SKProduct = InAppPurchase.getProductBy(identifier: "my_product") else { return }
productTitleLabel.text = product.localizedTitle
productDescriptionLabel.text = product.localizedDescription
productPriceLabel.text = product.localizedPrice
  • Initialize a purchase
self.loaderView.show()
InAppPurchase.purchase(
    productIdentifier: "my_product",
    callback: { result in
        self.loaderView.hide()
})
  • Unlock purchased content
if InAppPurchase.hasActivePurchase(for: "my_product") {
    // display content related to the product
}
  • Restore purchases
self.loaderView.show()
InAppPurchase.restorePurchases(
    callback: { result in
        self.loaderView.hide()
})

Documentation

See also:

Xcode Demo Project

Do not hesitate to check the demo project available on here: iap-swift-lib-demo.

Coding

Generate the documentation, using Jazzy, just by running jazzy from the root of the project.

Troubleshooting

Common issues are covered here: https://github.com/iridescent-dev/iap-swift-lib/wiki/Troubleshooting

License

InAppPurchaseLib is open-sourced library licensed under the MIT License. See LICENSE for details.

About

An easy-to-use Swift library for In-App Purchases, using Iaptic for receipts validation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%