Код: Выделить всё
eloadAllTimelines()static var title: LocalizedStringResource = "Open&Swith Task"
static var description: IntentDescription = IntentDescription("Open and swith device Task")
@Parameter(title: "devicesn")
var deviceSN: String
static var isDiscoverable: Bool = false
init() { }
init(deviceSN: String) {
self.deviceSN = deviceSN
}
typealias DefaultIntentResult = IntentResultContainer
func perform() async throws -> some IntentResult {
let state = await DataRequest.shared.asyncSmartRequest(id: deviceSN)
WidgetDataManager.update(state)
WidgetCenter.shared.reloadAllTimelines()
try? await Task.sleep(nanoseconds: 2_000_000_000)
WidgetDataManager.restore()
WidgetCenter.shared.reloadAllTimelines()
return DefaultIntentResult.result()
}
}
< /code>
Я просто хочу написать виджет, такой как Swichbot (выполнить действие, показать статус и статус восстановления), это правильный путь? Кто -нибудь знает?
Подробнее здесь: https://stackoverflow.com/questions/795 ... -switchbot
Мобильная версия