Instance Method

activateWithOptions:completionHandler:

Asynchronously activates an audio session on watchOS.

Declaration

- (void)activateWithOptions:(AVAudioSessionActivationOptions)options completionHandler:(void (^)(BOOL activated, NSError *error))handler;

Discussion

Use this method to play long-form audio—such as music, podcasts, or audio books—on Apple Watch. Before calling this method to activate longform playback, you must call setCategory:mode:routeSharingPolicy:options:error: and set the category to AVAudioSessionCategoryPlayback and route sharing policy to AVAudioSessionRouteSharingPolicyLongForm.

This method asynchronously activates the audio session. The system calls the completion handler as soon as the session has successfully activated or if the activation fails.

Playback of long-form audio on watchOS requires a Bluetooth audio route. If necessary, the system presents an audio route picker to the user, letting them choose the Bluetooth route. If the user has previously selected a Bluetooth route or if AirPods or other W1-equipped Bluetooth headphones are nearby, the system automatically picks the audio route without displaying a picker view to the user. If no applicable Bluetooth route is selected (either automatically or by the user), the system passes an error to the completion handler.

See Also

Activating the Audio Session

- setActive:error:

Activates or deactivates your app’s audio session.

- setActive:withOptions:error:

Activates or deactivates your app’s audio session using the specified options.