совершаю покупку без прислушивания к обновлениям транзакций
отсутствующие успешные покупки. Создайте задачу для итерации
transaction.updates при запуске. < /P>
< /blockquote>
Код: Выделить всё
extension AppDelegate {
func observeTransactionUpdates() {
Task {
for await result in Transaction.updates {
switch result {
case .verified(let transaction):
if transaction.productID == ProductID.scans_200_price_1_95.rawValue {
print("Grant 200 scans")
print("Transaction id: \(transaction.id)")
await transaction.finish()
}
case .unverified(_, let error):
print("Unverified transaction: \(error.localizedDescription)")
}
}
}
}
}
Когда пользователь нажимает кнопку покупки, я делаю следующее:
func purchase(_ product: Product) async {
do {
let result = try await product.purchase()
switch result
{
case let .success(.verified(transaction)):
print("Grant 200 scans")
print("Transaction id: \(transaction.id)")
await transaction.finish()
case let .success(.unverified(_, error)):
print("Purchase was successful but transaction/receipt can't be verified. This phone could be a jailbroken.")
print("Error: \(error.localizedDescription)")
break
case .pending:
print("Transaction is waiting on SCA (Strong Customer Authentication) or approval from Ask to Buy")
break
case .userCancelled:
print("Purchase was cancelled!")
break
@unknown default:
print("Purchase was failed!")
break
}
}
catch {
print("Purchase was failed!")
}
}
< /code>
Вы можете увидеть грант 200 сканирования < /code> выполняется в двух местах: < /p>
[*] Когда пользователь нажимает на покупку Кнопка
Когда наблюдается, ? Где мне предоставить пользователя 200 токенов?
Подробнее здесь: https://stackoverflow.com/questions/793 ... n-storekit
Мобильная версия