fix: General improvements on purchase restore

This commit is contained in:
Andrea Busi
2020-07-30 21:07:16 +02:00
parent e2fa2c0cde
commit 5e9c101990
2 changed files with 18 additions and 2 deletions
@@ -40,6 +40,8 @@ class SubscriptionsViewController: UITableViewController {
private var availability: EQNPurchaseAvailability?
/// Tells if products are loading
private var isLoading = false
/// Tells if a restore is in progress
private var isRestorePurchase = false
// MARK: - View Lifecycle
@@ -155,7 +157,8 @@ class SubscriptionsViewController: UITableViewController {
// MARK: - Actions
@objc func restoreTapped(_ sender: AnyObject) {
VersioneProProducts.store.restorePurchases()
isRestorePurchase = true
VersioneProProducts.store.restorePurchases()
}
// MARK: - Notifications
@@ -165,6 +168,15 @@ class SubscriptionsViewController: UITableViewController {
}
@objc func handlePurchaseNotification(_ notification: Notification) {
if isRestorePurchase {
isRestorePurchase = false
let alert = UIAlertController(title: NSLocalizedString("purchase_pro_restore_alert_title", comment: ""),
message: NSLocalizedString("purchase_pro_restore_alert_message", comment: ""), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
}
VersioneProProducts.store.loadPurchase()
loadData()
}