Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / apple / FindFamily / FindFamilyiOS / App / AppDelegate.swift

AppDelegate.swift32 lines · 1.3 KiBRaw
1import SwiftUI
2import UIKit
3import CoreLocation
4import UserNotifications
5
6final class AppDelegate: NSObject, UIApplicationDelegate {
7 var isLaunchedFromLocationEvent = false
8
9 func application(
10 _ application: UIApplication,
11 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
12 ) -> Bool {
13 isLaunchedFromLocationEvent = launchOptions?[.location] != nil
14 UIDevice.current.isBatteryMonitoringEnabled = true
15
16 // Request notification permission early (best-effort).
17 UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { _, _ in }
18
19 Task { @MainActor in
20 // Kick off the network / identity layer.
21 await Networking.shared.start()
22 // Subscribe to sharing-state changes first so a toggle that fires
23 // before the DB finishes loading is still picked up, then start
24 // location work only when we're actually sharing with someone —
25 // this is the iOS analog of LocationTrackingService on Android.
26 // The same gate runs on background relaunch from location events.
27 LocationsHandler.shared.beginMonitoringSharing()
28 LocationsHandler.shared.startLocationUpdatesIfSharing()
29 }
30 return true
31 }
32}