Files
LoveLiveMusicPlayerKMP/iosApp/WidgetExtension/BackgroundIntent.swift
T
2026-08-30 19:36:25 +08:00

31 lines
862 B
Swift

import AppIntents
import Foundation
@available(iOS 17, *)
public struct BackgroundIntent: AppIntent {
static public var title: LocalizedStringResource = "HomeWidget Background Intent"
@Parameter(title: "Widget URI")
var url: URL?
public init() {}
public init(url: URL?) {
self.url = url
}
public func perform() async throws -> some IntentResult {
NotificationCenter.default.post(
name: Notification.Name("fromWigetToRunner"),
object: nil,
userInfo: ["url": url?.absoluteString ?? ""]
)
return .result()
}
}
/// 在宿主进程中继续执行,使小组件点击能通知主 App(对齐 Flutter Runner/BackgroundIntent)。
@available(iOS 17, *)
@available(iOSApplicationExtension, unavailable)
extension BackgroundIntent: ForegroundContinuableIntent {}