diff Simoleon/Settings.swift @ 43:2eb05f396fcd v1.2

Fixes NavigationView bugs
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Mon, 26 Jul 2021 17:35:57 +0100
parents d25b02d439d4
children ce4eb7416b41
line wrap: on
line diff
--- a/Simoleon/Settings.swift	Mon Jul 26 15:35:06 2021 +0100
+++ b/Simoleon/Settings.swift	Mon Jul 26 17:35:57 2021 +0100
@@ -81,6 +81,7 @@
             }
         }
         .onAppear {
+            checkEntitlement()
             /*
              if selectedDefaultCurrency is empty -> view is appearing for the first time -> set initial default curency for picker
              else -> view is appearing after user selected another default currency -> save it to core data
@@ -124,15 +125,20 @@
      Check if user subscription is active
      */
     private func checkEntitlement() {
-        Purchases.shared.purchaserInfo { (purchaserInfo, error) in
-            if purchaserInfo?.entitlements["all"]?.isActive == true {
-                entitlementIsActive = true
-                print("Entitlement is active")
-            } else {
-                entitlementIsActive = false
-                print("Entitlement is NOT active")
+        #if targetEnvironment(simulator)
+            // We're in simulator
+            entitlementIsActive = true
+        #else
+            Purchases.shared.purchaserInfo { (purchaserInfo, error) in
+                if purchaserInfo?.entitlements["all"]?.isActive == true {
+                    entitlementIsActive = true
+                    print("Entitlement is active")
+                } else {
+                    entitlementIsActive = false
+                    print("Entitlement is NOT active")
+                }
             }
-        }
+        #endif
     }
 }