From b9aeb430fd41ad6e627e066022b1f7ebf1813e5d Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sun, 26 Jul 2020 12:29:21 +0200 Subject: [PATCH] Handle case when we cannot get subscription status This occurs in ios when the user is asked for their iTunes password and they press cancel. It seems with the current approach they will be asked for their password once a month. It seems a bit annoying. How can this be made better? --- lib/iap.dart | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/iap.dart b/lib/iap.dart index 1d930706..fd9d80a9 100644 --- a/lib/iap.dart +++ b/lib/iap.dart @@ -33,9 +33,22 @@ class InAppPurchases { } static Future confirmProPurchase() async { - var sub = await _subscriptionStatus(); - if (sub == null) { - Log.i("Failed to get subscription status"); + SubscriptionStatus sub; + + try { + sub = await _subscriptionStatus(); + if (sub == null) { + Log.i("Failed to get subscription status"); + return; + } + } catch (e, stackTrace) { + Log.e("Failed to get subscription status", ex: e, stacktrace: stackTrace); + Log.i("Disabling Pro mode as it has probably expired"); + + Settings.instance.proMode = false; + Settings.instance.proExpirationDate = ""; + Settings.instance.save(); + return; }