Created
August 5, 2024 22:25
-
-
Save yccheok/d29a0cc106335cca611ccd1edc1620dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently, I have modified three functions to insert Qonversion-related code. Can you help me review whether I have done it correctly? | |
I have another concern. If, after trying, I am not satisfied with the outcome and decide not to purchase any plan from Qonversion, will the newly added Qonversion-related code affect my app’s performance in production? | |
Thank you. | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
... | |
let config = Qonversion.Configuration(projectKey: "XXX", launchMode: .analytics) | |
Qonversion.initWithConfig(config) | |
return true | |
} | |
private func listenForTransactions() -> Task<Void, Error> { | |
return Task.detached { | |
//Iterate through any transactions which didn't come from a direct call to `purchase()`. | |
for await result in Transaction.updates { | |
do { | |
let transaction = try self.checkVerified(result) | |
//Deliver content to the user. | |
await self.updatePurchasedIdentifiers(transaction) | |
//https://documentation.qonversion.io/docs/analytics-mode | |
await QonversionSwift.shared.handleTransaction(transaction) | |
//Always finish a transaction. | |
await transaction.finish() | |
} catch { | |
//StoreKit has a receipt it can read but it failed verification. Don't deliver content to the user. | |
error_log(error) | |
} | |
} | |
} | |
} | |
func purchase(_ shop: Shop) async -> Bool { | |
guard let product = products.filter({ $0.id == shop.identifier }).first else { return false } | |
do { | |
//Begin a purchase. | |
let result = try await product.purchase() | |
switch result { | |
case .success(let verification): | |
let transaction = try checkVerified(verification) | |
//Deliver content to the user. | |
await updatePurchasedIdentifiers(transaction) | |
//https://documentation.qonversion.io/docs/analytics-mode | |
await QonversionSwift.shared.handleTransaction(transaction) | |
//Always finish a transaction. | |
await transaction.finish() | |
return true | |
case .userCancelled, .pending: | |
return false | |
default: | |
return false | |
} | |
} catch { | |
error_log(error) | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment