initial commit
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import UIKit
|
||||
|
||||
let widgetGroupId = "group.top.zhushenwudi.llmp"
|
||||
|
||||
@main
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
||||
) -> Bool {
|
||||
let userDefaults = UserDefaults(suiteName: widgetGroupId)
|
||||
userDefaults?.set(false, forKey: "isShutdown")
|
||||
registerHostNotifications()
|
||||
return true
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ application: UIApplication) {
|
||||
let userDefaults = UserDefaults(suiteName: widgetGroupId)
|
||||
userDefaults?.set(false, forKey: "isPlaying")
|
||||
userDefaults?.set("", forKey: "curJpLrc")
|
||||
userDefaults?.set("", forKey: "nextJpLrc")
|
||||
userDefaults?.set(true, forKey: "isShutdown")
|
||||
}
|
||||
|
||||
func application(
|
||||
_ application: UIApplication,
|
||||
configurationForConnecting connectingSceneSession: UISceneSession,
|
||||
options: UIScene.ConnectionOptions
|
||||
) -> UISceneConfiguration {
|
||||
if connectingSceneSession.role == UISceneSession.Role.carTemplateApplication {
|
||||
return UISceneConfiguration(
|
||||
name: "CarPlay Configuration",
|
||||
sessionRole: connectingSceneSession.role
|
||||
)
|
||||
}
|
||||
return UISceneConfiguration(
|
||||
name: "Default Configuration",
|
||||
sessionRole: connectingSceneSession.role
|
||||
)
|
||||
}
|
||||
|
||||
private func registerHostNotifications() {
|
||||
NotificationCenter.default.addObserver(
|
||||
forName: Notification.Name("llmpShareRequest"),
|
||||
object: nil,
|
||||
queue: .main
|
||||
) { notification in
|
||||
HostBridge.shared.presentShare(from: notification.userInfo)
|
||||
}
|
||||
NotificationCenter.default.addObserver(
|
||||
forName: Notification.Name("fromWidgetToHost"),
|
||||
object: nil,
|
||||
queue: .main
|
||||
) { notification in
|
||||
HostBridge.shared.handleWidgetAction(from: notification.userInfo)
|
||||
}
|
||||
NotificationCenter.default.addObserver(
|
||||
forName: Notification.Name("llmpCarPlayAction"),
|
||||
object: nil,
|
||||
queue: .main
|
||||
) { notification in
|
||||
HostBridge.shared.handleCarPlayAction(from: notification.userInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user