-
Notifications
You must be signed in to change notification settings - Fork 3
/
AppDelegate.swift
55 lines (44 loc) · 1.84 KB
/
AppDelegate.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
53
54
55
//
// AppDelegate.swift
// PushExample
//
// Created by Gary Tokman on 2/11/24.
//
import Foundation
import UIKit
import React
import candlefinance_push // 0
import NotificationCenter // 1
@UIApplicationMain
class AppDelegate: RCTAppDelegate {
var isDarkMode: Bool {
return UITraitCollection.current.userInterfaceStyle == .dark
}
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.moduleName = "PushExample"
UNUserNotificationCenter.current().delegate = self // 3
let result = super.application(application, didFinishLaunchingWithOptions: launchOptions)
return result
}
override func sourceURL(for bridge: RCTBridge!) -> URL! {
//#if DEBUG
print("DEBUG")
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
//#else
// print("PROD")
// return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
//#endif
}
}
// 4
extension AppDelegate: UNUserNotificationCenterDelegate {
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
PushNotificationAppDelegateHelper.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken)
}
override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: any Error) {
PushNotificationAppDelegateHelper.didFailToRegisterForRemoteNotificationsWithError(error)
}
override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
PushNotificationAppDelegateHelper.didReceiveRemoteNotification(userInfo: userInfo, completionHandler: completionHandler)
}
}