2024-08-29 13:09:16 +00:00
|
|
|
import AVFoundation
|
2024-09-01 10:42:31 +00:00
|
|
|
import Defaults
|
2022-01-02 19:41:04 +00:00
|
|
|
import Foundation
|
2024-08-29 13:09:16 +00:00
|
|
|
import Logging
|
2022-01-02 19:41:04 +00:00
|
|
|
import UIKit
|
|
|
|
|
|
|
|
final class AppDelegate: UIResponder, UIApplicationDelegate {
|
2024-09-01 10:42:31 +00:00
|
|
|
var orientationLock = UIInterfaceOrientationMask.allButUpsideDown
|
2022-01-02 19:41:04 +00:00
|
|
|
|
2024-09-01 10:42:31 +00:00
|
|
|
private var logger = Logger(label: "stream.yattee.app.delegate")
|
2022-01-02 19:41:04 +00:00
|
|
|
private(set) static var instance: AppDelegate!
|
|
|
|
|
|
|
|
func application(_: UIApplication, supportedInterfaceOrientationsFor _: UIWindow?) -> UIInterfaceOrientationMask {
|
2024-09-01 10:42:31 +00:00
|
|
|
return orientationLock
|
2022-01-02 19:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { // swiftlint:disable:this discouraged_optional_collection
|
2022-05-20 19:53:17 +00:00
|
|
|
Self.instance = self
|
2022-06-28 19:11:28 +00:00
|
|
|
|
2024-08-29 13:09:16 +00:00
|
|
|
#if !os(macOS)
|
|
|
|
UIViewController.swizzleHomeIndicatorProperty()
|
2022-07-09 22:29:13 +00:00
|
|
|
OrientationTracker.shared.startDeviceOrientationTracking()
|
2024-09-01 10:42:31 +00:00
|
|
|
OrientationModel.shared.startOrientationUpdates()
|
2024-08-29 13:09:16 +00:00
|
|
|
|
|
|
|
// Configure the audio session for playback
|
|
|
|
do {
|
|
|
|
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback)
|
|
|
|
} catch {
|
|
|
|
logger.error("Failed to set audio session category: \(error)")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Begin receiving remote control events
|
|
|
|
UIApplication.shared.beginReceivingRemoteControlEvents()
|
2022-06-21 22:18:16 +00:00
|
|
|
#endif
|
2024-08-29 13:09:16 +00:00
|
|
|
|
2022-01-02 19:41:04 +00:00
|
|
|
return true
|
|
|
|
}
|
2024-05-16 16:28:32 +00:00
|
|
|
|
|
|
|
func application(_: UIApplication, open url: URL, options _: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
|
2024-04-25 17:01:44 +00:00
|
|
|
if url.scheme == "yattee" {
|
2024-05-16 16:53:47 +00:00
|
|
|
OpenURLHandler(navigationStyle: Constants.defaultNavigationStyle).handle(url)
|
2024-04-25 17:18:10 +00:00
|
|
|
return true
|
2024-04-25 17:01:44 +00:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2022-01-02 19:41:04 +00:00
|
|
|
}
|