Open Jerland2 opened 5 years ago
The solution is to modify this block of code
public func restore(handler: ((_ result: InAppPurchase.Result<Void>) -> Void)?) {
paymentProvider.restoreCompletedTransactions { (_, error) in
if let error = error {
handler?(.failure(error))
return
}
handler?(.success(()))
}
}
and change it to:
public func restore(handler: ((_ result: InAppPurchase.Result<Void>) -> Void)?) {
paymentProvider.restoreCompletedTransactions { (queue, error) in
if let error = error {
handler?(.failure(error))
return
}
if queue.transactions.isEmpty {
let emptyProductsError = Error(error: Error.emptyProducts)
handler?(.failure(emptyProductsError))
return
} else {
handler?(.success(()))
}
}
}
@jinSasaki please let me know if you see any issues with this fix as you are no doubt more familiar with the library. If not this should be updated in the repo
It is not a bug.
I think that the restore feature should be always succeeded except StoreKit returned error, so this library returns success even if queue.transactions
is empty.
However, I think that the developers should be able to handle the restored result. InAppPurchase plans to add the product ids to result after the restore method called.
Please see also #26.
Describe the bug Whenever I use the current restore Product option it succeeds even when a user has not purchased the in app purchase
To Reproduce Steps to reproduce the behavior:
Expected behavior A user should be prompted to sign in to their iCloud account and it should fail if they have not purchased the product before