<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NearbyInteraction",
  "identifier" : "/documentation/NearbyInteraction/NISession/updateMotionState(_:forObjectWithToken:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Nearby Interaction"
    ],
    "preciseIdentifier" : "c:objc(cs)NISession(im)updateMotionState:forObjectWithToken:"
  },
  "title" : "updateMotionState(_:forObjectWithToken:)"
}
-->

# updateMotionState(_:forObjectWithToken:)

Notifies the session of an accessory’s motion state change.

```
func updateMotionState(_ motionState: NIMotionActivityState, forObjectWithToken token: NIDiscoveryToken)
```

## Parameters

`motionState`

The current motion state of the accessory.

`token`

The discovery token that identifies the nearby accessory.

## Discussion

Ranging accuracy improves when the framework knows whether the accessory is moving. Track your accessory’s motion using a method you choose and then describe the motion with the appropriate [`NIMotionActivityState`](/documentation/NearbyInteraction/NIMotionActivityState). Call this method, providing the motion state, when the accessory’s motion state changes:

```swift
func handleMotionStateUpdate(_ state: NIMotionActivityState, session: NISession) {
    guard let config = session.configuration as? NINearbyAccessoryConfiguration else {
        return
    }
    session.updateMotionState(state, forObjectWithToken: config.accessoryDiscoveryToken)
}
```

This method works with [`NINearbyAccessoryConfiguration`](/documentation/NearbyInteraction/NINearbyAccessoryConfiguration) sessions, and applies to Ultra Wideband and Bluetooth Channel Sounding sessions.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)