This is a general singleton In-App Purchase Manager that can be shared between apps or mutiple places in one app. You need to have a case for each ProductID
enum ProductId:String, CaseIterable {
// User defined and must be the same as AppStoreConnect
case Prod1 = "com.Prod1"
case Prod2 = "com.Prod2"
case Prod3 = "com.Prod3"
}
Below is how you can add InAppPurchaseManager to your app.
- Just add
InAppPurchaseManager.swiftto your project - Fetch Produts as soon as possible. We recommend the following in
AppDelegate.swiftfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { InAppPurchaseManager.shared.startTransactionListener() Task{ await InAppPurchaseManager.shared.fetchProducts() } .... return true }
If you liked this free repository, you can Buy me a coffee
