mirror of
https://github.com/ente-io/ente.git
synced 2025-05-25 12:32:38 +00:00
54 lines
1.8 KiB
Swift
54 lines
1.8 KiB
Swift
import Flutter
|
|
import UIKit
|
|
import AVFoundation
|
|
|
|
@main
|
|
@objc class AppDelegate: FlutterAppDelegate {
|
|
override func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
) -> Bool {
|
|
|
|
if #available(iOS 10.0, *) {
|
|
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
|
|
}
|
|
|
|
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
|
|
let audioSessionChannel = FlutterMethodChannel(name: "io.ente.frame/audio_session",
|
|
binaryMessenger: controller.binaryMessenger)
|
|
|
|
audioSessionChannel.setMethodCallHandler({
|
|
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
|
if call.method == "setAudioSessionCategory" {
|
|
self.setAudioSessionCategory(result: result)
|
|
} else {
|
|
result(FlutterMethodNotImplemented)
|
|
}
|
|
})
|
|
|
|
GeneratedPluginRegistrant.register(with: self)
|
|
|
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
}
|
|
|
|
private func setAudioSessionCategory(result: @escaping FlutterResult) {
|
|
do {
|
|
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.mixWithOthers, .defaultToSpeaker])
|
|
try AVAudioSession.sharedInstance().setActive(true)
|
|
result(nil)
|
|
} catch {
|
|
result(FlutterError(code: "AUDIO_SESSION_ERROR",
|
|
message: "Failed to set audio session category",
|
|
details: error.localizedDescription))
|
|
}
|
|
}
|
|
|
|
override func applicationDidBecomeActive(_ application: UIApplication) {
|
|
signal(SIGPIPE, SIG_IGN)
|
|
}
|
|
|
|
override func applicationWillEnterForeground(_ application: UIApplication) {
|
|
signal(SIGPIPE, SIG_IGN)
|
|
}
|
|
}
|