comparison Simoleon/Helpers/RestoreButton.swift @ 42:d25b02d439d4

Minor updates subscription and legal requirements
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Mon, 26 Jul 2021 15:35:06 +0100
parents f76d0e26c178
children c7b6249ab745
comparison
equal deleted inserted replaced
41:7703c122ce96 42:d25b02d439d4
8 import SwiftUI 8 import SwiftUI
9 import Purchases 9 import Purchases
10 10
11 struct RestoreButton: View { 11 struct RestoreButton: View {
12 @Binding var showingSubscriptionPaywall: Bool 12 @Binding var showingSubscriptionPaywall: Bool
13 @EnvironmentObject var subscriptionController: SubscriptionController
14 13
15 @State private var alertTitle: LocalizedStringKey = "" 14 @State private var alertTitle: LocalizedStringKey = ""
16 @State private var alertMessage: LocalizedStringKey = "" 15 @State private var alertMessage: LocalizedStringKey = ""
17 @State private var restoringPurchases = false 16 @State private var restoringPurchases = false
18 @State private var showingAlert = false 17 @State private var showingAlert = false
33 private func restorePurchases() { 32 private func restorePurchases() {
34 restoringPurchases = true 33 restoringPurchases = true
35 34
36 Purchases.shared.restoreTransactions { purchaserInfo, error in 35 Purchases.shared.restoreTransactions { purchaserInfo, error in
37 if purchaserInfo?.entitlements["all"]?.isActive == true { 36 if purchaserInfo?.entitlements["all"]?.isActive == true {
38 subscriptionController.isActive = true
39 showingSubscriptionPaywall = false 37 showingSubscriptionPaywall = false
40 } else { 38 } else {
41 alertTitle = LocalizedStringKey("No subscriptions found") 39 alertTitle = LocalizedStringKey("No subscriptions found")
42 alertMessage = LocalizedStringKey("You are not subscripted to Simoleon yet.") 40 alertMessage = LocalizedStringKey("You are not subscripted to Simoleon yet.")
43 restoringPurchases = false 41 restoringPurchases = false