Launching your voice-based conversational app from the side button of iPhone
Let people in Japan configure the side button of iPhone to launch your voice-based conversational app.
Overview
By adopting the App Intents framework and offering App Shortcuts, you let people instantly access app functionality and integrate it with system experiences like Spotlight or App Shortcuts. For example, a person might place an App Shortcut you provide on the Action button. In Japan, people might place an action on the side button of iPhone that instantly launches your voice-based conversational app. People expect the voice-based conversational functionality to be instantly available when they launch your app with the side button, so make sure to let them immediately use it by starting an audio session – for example, with AVFoundation.
To allow people to press and hold the side button to launch your voice-based conversational app to its conversation experience:
Add the
com.apple.developer.side-button-access.allowentitlement to the.entitlementsfile in your app’s Xcode project. For details on adding this entitlement, see Side Button Access.Create an app intent that conforms to the activate app intent schema.
In the app intent’s perform() implementation, navigate to the scene that provides voice-based conversational functionality and start an audio session.
The following example shows how an app that provides voice-based conversational functionality might implement an app intent that people in Japan can place on the side button of iPhone:
@AppIntent(schema: .assistant.activate)
struct ActivateVoiceBasedConversationSceneIntent {
static let supportedModes: IntentModes = .foreground
func perform() async throws -> some IntentResult {
// Add code here to navigate to the scene in your app that provides
// voice-based conversational functionality.
// If applicable, pass information to your app that allows it to update
// its data or UI in response to the invocation from
// the side button and start voice-based conversational functionality.
return .result()
}
}If you’re new to the AppIntents framework, refer to Creating your first app intent and Making actions and content discoverable and widely available for additional information.