Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion resources/ios/BSHArrivalMonitor.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import Foundation
import CoreLocation
import UIKit

/// Every launch hook of the plugin, run by `ios.init_function`.
enum BSHLaunch {
private static var launchObserver: NSObjectProtocol?

static func install() {
BSHNotificationCenter.install()
BSHArrivalMonitor.install()

// `init_function` runs in the SwiftUI `App.init`, before the app has finished
// launching: a location manager started there deadlocks the CoreMotion thread
// that ARKit needs, so tracking never initialises.
launchObserver = NotificationCenter.default.addObserver(
forName: UIApplication.didFinishLaunchingNotification,
object: nil,
queue: .main
) { _ in
if let observer = launchObserver {
NotificationCenter.default.removeObserver(observer)
launchObserver = nil
}

BSHArrivalMonitor.install()
}
}
}

Expand Down
Loading