Mercurial > public > simoleon
comparison Simoleon/Settings.swift @ 73:2b85d6ed433e
Implemented StoreKit Testing in Simulator
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Thu, 29 Jul 2021 10:51:08 +0100 |
parents | 3833a7d0a9f9 |
children | b6f8661300f2 |
comparison
equal
deleted
inserted
replaced
72:f9c598661700 | 73:2b85d6ed433e |
---|---|
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 // Check if user subscription is active | 151 // Check if user subscription is active |
152 private func checkEntitlement() { | 152 private func checkEntitlement() { |
153 #if targetEnvironment(simulator) | |
154 // We're in simulator | |
155 entitlementIsActive = true | |
156 #else | |
157 // We're in physical device | |
158 Purchases.shared.purchaserInfo { (purchaserInfo, error) in | 153 Purchases.shared.purchaserInfo { (purchaserInfo, error) in |
159 if purchaserInfo?.entitlements["all"]?.isActive == true { | 154 if purchaserInfo?.entitlements["all"]?.isActive == true { |
160 entitlementIsActive = true | 155 entitlementIsActive = true |
161 } else { | 156 } else { |
162 entitlementIsActive = false | 157 entitlementIsActive = false |
166 alertTitle = error.localizedDescription | 161 alertTitle = error.localizedDescription |
167 alertMessage = error.localizedFailureReason ?? "" | 162 alertMessage = error.localizedFailureReason ?? "" |
168 showingAlert = true | 163 showingAlert = true |
169 } | 164 } |
170 } | 165 } |
171 #endif | |
172 } | 166 } |
173 } | 167 } |
174 | 168 |
175 struct Settings_Previews: PreviewProvider { | 169 struct Settings_Previews: PreviewProvider { |
176 static var previews: some View { | 170 static var previews: some View { |