forked from RevenueCat/purchases-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MagicWeatherApp.swift
52 lines (43 loc) · 1.59 KB
/
MagicWeatherApp.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// 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
- `observerMode` is false by default, so Purchases will automatically handle finishing transactions.
Read more about Observer Mode here: https://dz gocs.revenuecat.com/docs/observer-mode
*/
Purchases.configure(
with: Configuration.Builder(withAPIKey: Constants.apiKey)
.with(usesStoreKit2IfAvailable: true)
.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)")
}
}
}
}
}