|
14 | 14 | // limitations under the License. |
15 | 15 | // |
16 | 16 |
|
17 | | -import SwiftUI |
18 | 17 | import FirebaseCore |
19 | 18 | import FirebaseCrashlytics |
| 19 | +import SwiftUI |
20 | 20 |
|
21 | 21 | @main |
22 | 22 | struct CrashlyticsSwiftUIExampleApp: App { |
23 | | - private var crashlyticsReference = Crashlytics.crashlytics() |
24 | | - let reachabilityHelper = ReachabililtyHelper() |
| 23 | + private var crashlyticsReference = Crashlytics.crashlytics() |
| 24 | + let reachabilityHelper = ReachabililtyHelper() |
25 | 25 |
|
26 | | - func setUserInfo() { |
27 | | - let userInfo = [ |
28 | | - NSLocalizedDescriptionKey: NSLocalizedString("The request failed.", comment: ""), |
29 | | - NSLocalizedFailureReasonErrorKey: NSLocalizedString( |
30 | | - "The response returned a 404.", |
31 | | - comment: "" |
32 | | - ), |
33 | | - NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString( |
34 | | - "Does this page exist?", |
35 | | - comment: "" |
36 | | - ), |
37 | | - "ProductID": "123456", |
38 | | - "UserID": "Jane Smith", |
39 | | - ] |
40 | | - let error = NSError(domain: NSURLErrorDomain, code: -1001, userInfo: userInfo) |
41 | | - Crashlytics.crashlytics().record(error: error) |
42 | | - } |
| 26 | + func setUserInfo() { |
| 27 | + let userInfo = [ |
| 28 | + NSLocalizedDescriptionKey: NSLocalizedString("The request failed.", comment: ""), |
| 29 | + NSLocalizedFailureReasonErrorKey: NSLocalizedString( |
| 30 | + "The response returned a 404.", |
| 31 | + comment: "" |
| 32 | + ), |
| 33 | + NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString( |
| 34 | + "Does this page exist?", |
| 35 | + comment: "" |
| 36 | + ), |
| 37 | + "ProductID": "123456", |
| 38 | + "UserID": "Jane Smith", |
| 39 | + ] |
| 40 | + let error = NSError(domain: NSURLErrorDomain, code: -1001, userInfo: userInfo) |
| 41 | + Crashlytics.crashlytics().record(error: error) |
| 42 | + } |
43 | 43 |
|
44 | | - func setCustomValues() { |
45 | | - crashlyticsReference.setCustomValue(42, forKey: "MeaningOfLife") |
46 | | - crashlyticsReference.setCustomValue("Test value", forKey: "last_UI_action") |
47 | | - let customKeysObject = [ |
48 | | - "locale": reachabilityHelper.getLocale(), |
49 | | - "network_connection": reachabilityHelper.getNetworkStatus(), |
50 | | - ] as [String: Any] |
51 | | - crashlyticsReference.setCustomKeysAndValues(customKeysObject) |
52 | | - reachabilityHelper.updateAndTrackNetworkStatus() |
53 | | - Crashlytics.crashlytics().setUserID("123456789") |
54 | | - } |
| 44 | + func setCustomValues() { |
| 45 | + crashlyticsReference.setCustomValue(42, forKey: "MeaningOfLife") |
| 46 | + crashlyticsReference.setCustomValue("Test value", forKey: "last_UI_action") |
| 47 | + let customKeysObject = [ |
| 48 | + "locale": reachabilityHelper.getLocale(), |
| 49 | + "network_connection": reachabilityHelper.getNetworkStatus(), |
| 50 | + ] as [String: Any] |
| 51 | + crashlyticsReference.setCustomKeysAndValues(customKeysObject) |
| 52 | + reachabilityHelper.updateAndTrackNetworkStatus() |
| 53 | + Crashlytics.crashlytics().setUserID("123456789") |
| 54 | + } |
55 | 55 |
|
56 | | - init() { |
57 | | - FirebaseApp.configure() |
58 | | - Crashlytics.crashlytics().log("App loaded") |
59 | | - setCustomValues() |
60 | | - setUserInfo() |
61 | | - } |
| 56 | + init() { |
| 57 | + FirebaseApp.configure() |
| 58 | + Crashlytics.crashlytics().log("App loaded") |
| 59 | + setCustomValues() |
| 60 | + setUserInfo() |
| 61 | + } |
62 | 62 |
|
63 | | - var body: some Scene { |
64 | | - WindowGroup { |
65 | | - ContentView() |
| 63 | + var body: some Scene { |
| 64 | + WindowGroup { |
| 65 | + ContentView() |
| 66 | + } |
66 | 67 | } |
67 | | - } |
68 | 68 | } |
0 commit comments