Add support for tvOS

This commit is contained in:
世界
2023-07-29 09:44:31 +08:00
parent 5a8f3a770f
commit bb0385f53c
63 changed files with 1542 additions and 389 deletions
+21 -1
View File
@@ -1,12 +1,16 @@
import ApplicationLibrary
import Foundation
import Libbox
import Library
import Network
import UIKit
class ApplicationDelegate: NSObject, UIApplicationDelegate {
private var profileServer: ProfileServer?
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
NSLog("Here I stand")
ServiceNotification.register()
LibboxSetup(FilePath.sharedDirectory.relativePath, FilePath.workingDirectory.relativePath, FilePath.cacheDirectory.relativePath, false)
Task.detached {
do {
try await UIProfileUpdateTask.setup()
@@ -18,9 +22,25 @@ class ApplicationDelegate: NSObject, UIApplicationDelegate {
Task.detached {
await self.requestNetworkPermission()
}
if #available(iOS 16.0, *) {
Task.detached {
await self.setupProfileServer()
}
}
return true
}
@available(iOS 16.0, *)
private func setupProfileServer() {
do {
let profileServer = try ProfileServer()
profileServer.start()
self.profileServer = profileServer
} catch {
NSLog("setup profile server error: \(error.localizedDescription)")
}
}
private func requestNetworkPermission() {
if UIDevice.current.userInterfaceIdiom != .phone {
return