Instance Method

sessionDidDeactivate(_:)

Called after all data from the previous session has been delivered and communication with the Apple Watch has ended.

Required.

Declaration

func sessionDidDeactivate(_ session: WCSession)

Parameters

session

The session object whose activation state changed.

Discussion

You must implement this method to support quick switching between Apple Watch devices in your iOS app. The session calls this method when there is no more pending data to deliver to your app and the previous session can be formally closed.

When this method is called, call the activate() method again to initiate a session with the new Apple Watch, as shown in Listing 1. You can also perform any final cleanup tasks related to closing out the previous session.

Listing 1

Handling the deactivation of the session

func sessionDidDeactivate(session: WCSession) {
    // Begin the activation process for the new Apple Watch.
    WCSession.defaultSession().activateSession()
}

See Also

Managing Session Activation

func sessionDidBecomeInactive(WCSession)

Called when the session prepares to stop communicating with the current Apple Watch.

Required.