Apple Nearby Interaction for UWB in iOS app

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Apple Nearby Interaction for UWB in iOS app
Medium
~5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Integrating Nearby Interaction (Apple UWB) into iOS App

Nearby Interaction — Apple framework for precise distance and direction measurement to another iPhone or accessory with U1/U2 chip. Not Bluetooth proximity, not iBeacon, not GPS. UWB (Ultra Wideband) works at centimeter accuracy: app receives distance in meters with ±10–15 cm precision and direction — 3D vector to device in space (on iPhone 14 Pro+ via dual-directional antennas).

Used for: precise aiming in file sharing and payments, finding lost items (like AirTag), smart home control with spatial binding, AR apps with real spatial anchoring.

Limitations to Know Before Start

iPhone 11+ only. U1 chip first appeared in iPhone 11. iPhone SE (all generations) — no UWB. iPad — no UWB (except specialized configs). App must check NISession.deviceCapabilities.supportsPreciseDistanceMeasurement.

Foreground only. NISession works when app active. No exceptions. Measurement in background — UWB unsuitable, hardware limitation.

Two devices, one session. For P2P measurement both devices must create NISession and exchange NIDiscoveryToken. Token can't be shared beforehand — generated on session creation and changes on restart. Token exchange via MultipeerConnectivity, Bluetooth, server — your choice.

How Session Works

import NearbyInteraction
import MultipeerConnectivity

class UWBSessionManager: NSObject, NISessionDelegate {
  private var niSession = NISession()
  private var peerToken: NIDiscoveryToken?

  override init() {
    super.init()
    niSession.delegate = self
  }

  func startSession(with peerToken: NIDiscoveryToken) {
    let config = NINearbyPeerConfiguration(peerToken: peerToken)
    config.isCameraAssistanceEnabled = true  // Camera Assistance on iPhone 14 Pro+
    niSession.run(config)
  }

  func session(_ session: NISession,
               didUpdate nearbyObjects: [NINearbyObject]) {
    guard let peer = nearbyObjects.first else { return }

    if let distance = peer.distance {
      print("Distance: \(distance) m")
    }
    if let direction = peer.direction {
      print("Direction: \(direction)")  // simd_float3
    }
  }

  func session(_ session: NISession,
               didInvalidateWith error: Error) {
    // NIErrorCode.userDidNotAllow, .resourceUsageLimitReached, .sessionFailed
    // on .resourceUsageLimitReached — just restart session
  }
}

Token Exchange via MultipeerConnectivity

Most common approach for P2P: use MCSession for token transfer, then start NISession. Important: NIDiscoveryToken can't pass as string — it's Codable, encode via NSKeyedArchiver:

let tokenData = try NSKeyedArchiver.archivedData(
  withRootObject: niSession.discoveryToken!,
  requiringSecureCoding: true
)
mcSession.send(tokenData, toPeers: peers, with: .reliable)

Receiving side:

let token = try NSKeyedUnarchiver.unarchivedObject(
  ofClass: NIDiscoveryToken.self,
  from: data
)

JSON encoding attempt — won't work, NIDiscoveryToken not standard Encodable.

Camera Assistance

iPhone 14 Pro and 15 series support isCameraAssistanceEnabled = true. System shows native AR overlay helping aim at device. User sees direction arrow. Activates only with camera permission. Adds ~200 ms latency before first direction data.

Work Included

  • Device compatibility check (NIDeviceCapability)
  • NISession setup with P2P or accessory config (NINearbyAccessoryConfiguration)
  • NIDiscoveryToken exchange mechanism (MultipeerConnectivity, Bluetooth, REST)
  • Real-time distance/direction update handling
  • Camera Assistance overlay
  • Error handling and session restart
  • Testing on two physical devices (simulator UWB unsupported)

Timeline

5 days. Testing needs two real iPhones with U1/U2 — simulator insufficient. Cost calculated individually after analyzing use case.