initial commit
This commit is contained in:
29
iosApp/WidgetExtension/BackgroundIntent.swift
Normal file
29
iosApp/WidgetExtension/BackgroundIntent.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
import AppIntents
|
||||
import Foundation
|
||||
|
||||
@available(iOS 17, *)
|
||||
public struct BackgroundIntent: AppIntent {
|
||||
static public var title: LocalizedStringResource = "LLMP Widget Action"
|
||||
|
||||
@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("fromWidgetToHost"),
|
||||
object: nil,
|
||||
userInfo: ["url": url?.absoluteString ?? ""]
|
||||
)
|
||||
return .result()
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 17, *)
|
||||
@available(iOSApplicationExtension, unavailable)
|
||||
extension BackgroundIntent: ForegroundContinuableIntent {}
|
||||
Reference in New Issue
Block a user