2021-01-29 14:36:54 -05:00
|
|
|
//
|
2021-01-29 14:42:07 -05:00
|
|
|
// MagicWeatherApp.swift
|
|
|
|
|
// Magic Weather SwiftUI
|
2021-01-29 14:36:54 -05:00
|
|
|
//
|
|
|
|
|
// Created by Cody Kerns on 1/11/21.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import SwiftUI
|
2021-09-03 14:17:37 -03:00
|
|
|
import RevenueCat
|
2021-01-29 14:36:54 -05:00
|
|
|
|
|
|
|
|
@main
|
|
|
|
|
struct MagicWeatherApp: App {
|
|
|
|
|
|
|
|
|
|
init() {
|
|
|
|
|
/* Enable debug logs before calling `configure`. */
|
2021-10-22 15:59:13 -07:00
|
|
|
Purchases.logLevel = .debug
|
2021-01-29 14:36:54 -05:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Initialize the RevenueCat Purchases SDK.
|
|
|
|
|
|
2022-05-26 13:20:05 -07:00
|
|
|
- `appUserID` is nil by default, so an anonymous ID will be generated automatically by the Purchases SDK.
|
|
|
|
|
Read more about Identifying Users here: https://docs.revenuecat.com/docs/user-ids
|
2024-07-01 12:37:21 -07:00
|
|
|
|
2021-01-29 14:36:54 -05:00
|
|
|
*/
|
2021-12-14 09:55:45 -08:00
|
|
|
|
2022-05-26 13:20:05 -07:00
|
|
|
Purchases.configure(
|
|
|
|
|
with: Configuration.Builder(withAPIKey: Constants.apiKey)
|
2024-07-01 12:37:21 -07:00
|
|
|
.with(storeKitVersion: .storeKit2)
|
2022-05-26 13:20:05 -07:00
|
|
|
.build()
|
|
|
|
|
)
|
|
|
|
|
|
2021-01-29 14:36:54 -05:00
|
|
|
/* Set the delegate to our shared instance of PurchasesDelegateHandler */
|
|
|
|
|
Purchases.shared.delegate = PurchasesDelegateHandler.shared
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var body: some Scene {
|
|
|
|
|
WindowGroup {
|
|
|
|
|
ContentView()
|
|
|
|
|
.preferredColorScheme(.dark)
|
2022-05-26 13:57:25 -07:00
|
|
|
.task {
|
|
|
|
|
do {
|
|
|
|
|
// Fetch the available offerings
|
|
|
|
|
UserViewModel.shared.offerings = try await Purchases.shared.offerings()
|
|
|
|
|
} catch {
|
|
|
|
|
print("Error fetching offerings: \(error)")
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-29 14:36:54 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|