Contents

updateApplicationContext(_:)

Sends a dictionary of values that a paired and active device can use to synchronize its state.

Declaration

func updateApplicationContext(_ applicationContext: [String : Any]) throws

Parameters

  • applicationContext:

    A dictionary of property list values. You define the meaning of the dictionary contents. This parameter must not be nil.

Discussion

Use this method to transfer a dictionary of data items to the counterpart app. The system sends context data when the opportunity arises, with the goal of having the data ready to use by the time the counterpart wakes up. The counterpart’s session delivers the data to the session(_:didReceiveApplicationContext:) method of its delegate. A counterpart can also retrieve the data from the receivedApplicationContext property of its session.

This method replaces the previous dictionary that was set, so you should use this method to communicate state changes or to deliver data that is updated frequently anyway. For example, this method is well suited for updating your app’s glance.

You may call this method when the counterpart is not currently reachable.

This method can only be called while the session is active—that is, the activationState property is set to WCSessionActivationState.activated. Calling this method for an inactive or deactivated session is a programmer error.

See Also

Managing Background Updates