From a6fba3d2e7453fae04007fb1f1e809fdc6bf39a6 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 21 Jul 2020 10:37:01 +0200 Subject: [PATCH] IAP: Do not check for pro mode on boot If the user has freshly installed the app, they can click on the Purchase Pro Mode button and that will put them in Pro mode if already bought. This is being done, because otherwise the experience in ios is shitty as the moment the app is launched, the user is asked for their iTunes password. --- lib/app.dart | 2 +- lib/iap.dart | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index 7b209201..8047dc58 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -97,7 +97,7 @@ class JournalApp extends StatefulWidget { ), ); - InAppPurchases.confirmProPurchase(); + InAppPurchases.confirmProPurchaseBoot(); runApp(EasyLocalization( child: app, diff --git a/lib/iap.dart b/lib/iap.dart index 1ad6941d..34ad0262 100644 --- a/lib/iap.dart +++ b/lib/iap.dart @@ -9,12 +9,16 @@ import 'package:http/http.dart' as http; import 'package:gitjournal/settings.dart'; class InAppPurchases { - static Future confirmProPurchase() async { + static Future confirmProPurchaseBoot() async { + if (Settings.instance.proMode == false) { + Log.i("confirmProPurchaseBoot: Pro Mode is false"); + return; + } + var currentDt = DateTime.now().toUtc().toIso8601String(); var exp = Settings.instance.proExpirationDate; Log.i("Checking if ProMode should be enabled. Exp: $exp"); - if (exp != null && exp.isNotEmpty && exp.compareTo(currentDt) > 0) { Log.i("Not checking PurchaseInfo as exp = $exp and cur = $currentDt"); return; @@ -25,6 +29,10 @@ class InAppPurchases { return; } + return confirmProPurchase(); + } + + static Future confirmProPurchase() async { var sub = await _subscriptionStatus(); if (sub == null) { Log.i("Failed to get subscription status");