Implementing proximity-based interactions between a phone and watch
Interact with a nearby Apple Watch by measuring its distance to a paired iPhone.
Overview
Configure the Sample Code Project
You can run this sample either in the simulator or on paired devices. When running on paired devices, both the watch and iPhone must contain an Ultra Wideband chip.
To run on paired devices:
Select the WatchNIDemo target, then change the bundle ID to
<Your iOS app bundle ID>. Select the right team to let Xcode automatically manage your provisioning profile.Repeat step 1 for the WatchKit app and WatchKit Extension target. The bundle IDs should be
<Your iOS app bundle ID>.watchkitappand<Your iOS app bundle ID>.watchkitapp.watchkitextensionrespectively.Next, for the WatchKit app target, select the Info tab, and change the value of
WKCompanionAppBundleIdentifierkey to<Your iOS app bundle ID>.Finally, open the
Info.plistfile of the WatchKit Extension target, navigate toNSExtension>NSExtensionAttributes>WKAppBundleIdentifierkey, and change the value of the key to<Your iOS app bundle ID>.watchkitapp.