Spot the bug
Tap the line that makes this purchase flow unsafe.
func buy(_ product: Product) async throws {let result = try await product.purchase()switch result {case .success(let verification):let transaction = verification.unsafePayloadValueunlockPremium(for: transaction.productID)await transaction.finish()case .userCancelled, .pending:break@unknown default:break}}
Hint 1 of 1
What does 'unsafe' skip?
Choose an answer, then open Show answer below to check it.
Show answer
- Answer: line 5
let transaction = verification.unsafePayloadValue
Line 5 skips verification. Switch on the result and unlock only for .verified(let transaction), or use try verification.payloadValue, which throws when unverified.