I have an AppIntent that is provided as a shortcut and allows the user to open the app from Spotlight in iOS 17. When the shortcut is run, it opens the app with:
static let openAppWhenRun: Bool = true
I want to perform an action inside the app when it is opened, link the "New Note" action creates a new not in iOS 17.
How can I call the function within the app, or get the data passed by the AppIntent, so that the main app can process this data and perform the action.
I have tried sending a NotificationCenter
notification from the perform
function in the App Intent, but this seems very slow once the app has opened.
func perform() async throws -> some IntentResult {
NotificationCenter.default.post(name: Notification.Name(rawValue: "performFunctionInApp"), object: nil)
return .result()
}