I have implemented an AppIntent in my app with the purpose of allowing users to set up an automation within the Shortcuts app that runs based on a boolean value in my app.
It works well normally, but I've found that if my app is force quit, the Shortcut no longer works (presumably because it can't fetch the value of the boolean from my app anymore).
Does anyone know how to persist this value so that the Shortcut will work regardless of whether my app is open in the background?
Here is my implementation of the AppIntent:
struct my_automation: AppIntent {
static var title: LocalizedStringResource = "Automation Name"
var isTrue = UserDefaults.standard.bool(forKey: "myVal")
func perform() async throws -> some IntentResult {
return .result(value: isTrue)
}
}