-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppDelegate.swift
More file actions
73 lines (63 loc) ยท 2.29 KB
/
AppDelegate.swift
File metadata and controls
73 lines (63 loc) ยท 2.29 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// AppDelegate.swift
// App
//
// Created by ๊น๋ฏผํธ on 6/27/24.
//
import SwiftUI
import UIKit
import ComposableArchitecture
import Firebase
import FirebaseMessaging
import GoogleSignIn
import Dependencies
final class AppDelegate: NSObject {
@Dependency(\.amplitude)
private var amplitude
let store = Store(initialState: AppDelegateFeature.State()) {
AppDelegateFeature()
}
}
//MARK: - UIApplicationDelegate
extension AppDelegate: UIApplicationDelegate {
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if GIDSignIn.sharedInstance.handle(url) { return true }
return false
}
/// - ์ฑ์ ์คํํ ์ค๋น๊ฐ ๋์์ ๋
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
self.store.send(.didFinishLaunching)
// ์ด์์ฒด์ ๋ฒ์ (ex: "iOS 18.0.0")
let osVersion = "iOS \(UIDevice.current.systemVersion)"
// ์ฑ ๋ฒ๋ค ๋ฒ์ (ex: "2.0.1")
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
let amplitudeKey = Bundle.main.infoDictionary?["AMPLITUDE_API_KEY"] as? String ?? ""
amplitude.initialize(amplitudeKey, nil)
amplitude.track(.app_open(deviceOS: osVersion, appVersion: appVersion))
return true
}
/// - APNs์ ์ฑ๊ณต์ ์ผ๋ก ๋ฑ๋ก๋์์ ๋
func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
Messaging.messaging().apnsToken = deviceToken
Messaging.messaging().token { token, error in
if let error {
self.store.send(.didRegisterForRemoteNotifications(.failure(error)))
} else if let token {
self.store.send(.didRegisterForRemoteNotifications(.success(token)))
}
}
}
/// - APNs์ ๋ฑ๋กํ ์ ์์ ๋
func application(
_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: any Error
) {
self.store.send(.didRegisterForRemoteNotifications(.failure(error)))
}
}