Contents

registerForLaunch(onQuickSwitchStateEvents:)

Registers the calling app for background launch whenever the device’s quick switch state changes.

Declaration

func registerForLaunch(onQuickSwitchStateEvents completionHandler: @escaping  @Sendable ((any Error)?) -> Void)
func registerForLaunchOnQuickSwitchStateEvents() async throws

Parameters

  • completionHandler:

    A completion handler the framework calls after processing the request. The parameter passed to the completion handler indicates whether the request succeeded, failed, or ended in an unknown state.

Discussion

Call this method when you want to register the current device to receive quick switch event notifications when your app isn’t running.

If an app successfully registers to receive these events, the system allocates runtime to the app to process state changes even if it’s not currently running at the time of a stage change.

Registration persists until the app explicitly removes itself with unregisterForLaunch(onQuickSwitchStateEvents:).

The framework calls the completion handler with a non-nil error if the app is not eligible to register.

See Also

Registering and unregistering for quick switch events