Adds refresh of purchases when opening the app

sync2
Laurent 8 months ago
parent 7c7aee398a
commit 298ad297e8
  1. 2
      PadelClub/AppDelegate.swift
  2. 11
      PadelClub/Data/DataStore.swift

@ -24,6 +24,8 @@ class AppDelegate : NSObject, UIApplicationDelegate, UNUserNotificationCenterDel
return true
}
// MARK: - Remote Notifications
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
if StoreCenter.main.hasToken() {

@ -98,6 +98,11 @@ class DataStore: ObservableObject {
NotificationCenter.default.addObserver(self, selector: #selector(collectionDidLoad), name: NSNotification.Name.CollectionDidLoad, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(collectionDidUpdate), name: NSNotification.Name.CollectionDidChange, object: nil)
NotificationCenter.default.addObserver(
self,
selector: #selector(_willEnterForegroundNotification),
name: UIScene.willEnterForegroundNotification,
object: nil)
}
@ -169,6 +174,12 @@ class DataStore: ObservableObject {
self.objectWillChange.send()
}
@objc func _willEnterForegroundNotification() {
Task {
try await self.purchases.loadDataFromServerIfAllowed(clear: true)
}
}
func disconnect() {
Task {

Loading…
Cancel
Save