Files
purchases-ios/Examples/MagicWeatherSwiftUI/Shared/Sources/Lifecycle/MagicWeatherApp.swift
T

50 lines
1.4 KiB
Swift
Raw Normal View History

2021-01-29 14:36:54 -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.
- `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
Purchases.configure(
with: Configuration.Builder(withAPIKey: Constants.apiKey)
2024-07-01 12:37:21 -07:00
.with(storeKitVersion: .storeKit2)
.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)
.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
}
}
}