mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
51 lines
1.4 KiB
Swift
51 lines
1.4 KiB
Swift
//
|
|
// MagicWeatherApp.swift
|
|
// Magic Weather SwiftUI
|
|
//
|
|
// Created by Cody Kerns on 1/11/21.
|
|
//
|
|
|
|
import SwiftUI
|
|
import RevenueCat
|
|
|
|
@main
|
|
struct MagicWeatherApp: App {
|
|
|
|
init() {
|
|
/* Enable debug logs before calling `configure`. */
|
|
Purchases.logLevel = .debug
|
|
|
|
/*
|
|
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
|
|
|
|
*/
|
|
|
|
Purchases.configure(
|
|
with: Configuration.Builder(withAPIKey: Constants.apiKey)
|
|
.with(storeKitVersion: .storeKit2)
|
|
.build()
|
|
)
|
|
|
|
/* 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)")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|