An easy-to-use Swift library for In-App Purchases, using Fovea.Billing for receipts validation.
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.
InAppPurchase.initialize(
iapProducts: [ IAPProduct(productIdentifier: "my_product", productType: .nonConsumable) ],
validatorUrlString: "https://validator.fovea.cc/v1/validate?appName=demo&apiKey=12345678"
)
InAppPurchase.stop()
guard let product: SKProduct = InAppPurchase.getProductBy(identifier: "my_product") else { return }
productTitleLabel.text = product.localizedTitle
productDescriptionLabel.text = product.localizedDescription
productPriceLabel.text = product.localizedPrice
self.loaderView.show()
InAppPurchase.purchase(
productIdentifier: "my_product",
callback: { result in
self.loaderView.hide()
})
if InAppPurchase.hasActivePurchase(for: "my_product") {
// display content related to the product
}
self.loaderView.show()
InAppPurchase.restorePurchases(
callback: { result in
self.loaderView.hide()
})
See also:
Do not hesitate to check the demo project available on here: iap-swift-lib-demo.
Generate the documentation, using Jazzy, just by running jazzy
from the root of the project.
Common issues are covered here: https://github.com/iridescent-dev/iap-swift-lib/wiki/Troubleshooting
InAppPurchaseLib is open-sourced library licensed under the MIT License. See LICENSE for details.
link |
Stars: 4 |
Last commit: 2 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics