Nearby Interaction

RSS for tag

Locate and interact with nearby devices using distance, direction, and identifier.

Nearby Interaction Documentation

Posts under Nearby Interaction tag

45 Posts
Sort by:
Post not yet marked as solved
0 Replies
49 Views
Hi all I am going to develop a software for third party-UWB chipset communication with U1. From the document, third party chipset have to send the UWBConfigData to U1, but I have no idea how to fill in Manufacturer ID and UWB chipset model ID . anyone can help? Terence
Posted Last updated
.
Post not yet marked as solved
1 Replies
147 Views
I'm testing some nearby interaction on simulators. I was able to get updates in NISession but my app crashes unexpectedly. I have checked that the session is not getting invalidated. The errors have to do with NIExportedObjectForwarder. Can anyone explain what it does or what's causing this error? 2022-06-14 17:09:23.895783-0700 Threads[23791:8863595] -[NIExportedObjectForwarder didUpdateNearbyObjects:]: unrecognized selector sent to instance 0x600002d12550 2022-06-14 17:09:23.896240-0700 Threads[23791:8863595] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NIExportedObjectForwarder didUpdateNearbyObjects:]: unrecognized selector sent to instance 0x600002d12550' *** First throw call stack: ( 0   CoreFoundation                      0x00000001072e3d70 __exceptionPreprocess + 236 1   libobjc.A.dylib                     0x0000000104ffe14c objc_exception_throw + 56 2   CoreFoundation                      0x00000001072f32f4 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0 3   CoreFoundation                      0x00000001072e7fe0 ___forwarding___ + 1440 4   CoreFoundation                      0x00000001072ea07c _CF_forwarding_prep_0 + 92 5   NearbyInteraction                   0x0000000105100c74 -[NIServerConnection _sendDistanceUpdateForRequestedPeer:forPeer:] + 1544 6   NearbyInteraction                   0x0000000105100e18 -[NIServerConnection handleDistanceUpdate:] + 312 7   NearbyInteraction                   0x0000000105101e0c __54-[NIServerConnection handleEventFromSimulatorOnQueue:]_block_invoke + 316 8   libdispatch.dylib                   0x000000010657833c _dispatch_call_block_and_release + 24 9   libdispatch.dylib                   0x0000000106579b94 _dispatch_client_callout + 16 10  libdispatch.dylib                   0x0000000106580cc4 _dispatch_lane_serial_drain + 764 11  libdispatch.dylib                   0x0000000106581978 _dispatch_lane_invoke + 436 12  libdispatch.dylib                   0x000000010658da00 _dispatch_workloop_worker_thread + 812 13  libsystem_pthread.dylib             0x00000001cc0adb40 _pthread_wqthread + 284 14  libsystem_pthread.dylib             0x00000001cc0ac904 start_wqthread + 8 ) libc++abi: terminating with uncaught exception of type NSException
Posted
by jnsukm.
Last updated
.
Post not yet marked as solved
0 Replies
125 Views
Hi, The documentation for NISession says: One session represents an interaction between the user and a single nearby object. To interact with multiple nearby objects, create a separate session for each. However, NISessionDelegate method session (NISession,  didUpdate : [NINearbyObject]) take multiple nearby objects as a parameter. I find these two contradicting each other. Is it even possible to add multiple peers for a single session? If so, what's the best practice to do that? JK
Posted
by jnsukm.
Last updated
.
Post not yet marked as solved
1 Replies
176 Views
Hello, I wonder if multicast is possible on the third-party device side. If I understand correctly, all devices in a multicast session have the same session ID. As the iPhone decides this parameter, I will never be able to use this feature on my third-party device. Am I correct ? Is it possible to connect more than 5 iPhone to a third-party UWB device ? Thanks for reading me!
Posted
by Red13.
Last updated
.
Post not yet marked as solved
0 Replies
221 Views
Hello, We are a company working on Ultra Wideband solutions and, hence, using Apple's NearbyInteraction framework to establish UWB Ranging sessions with our UWB-enabled third-party accessory. This week we were excited about the new background UWB Ranging session possibility, which opens new use cases. The wwdc2022 10008 video that provides the technical details for this feature indicates that the third-party accessory is responsible to expose the Nearby Interaction GATT Server. We don't manage to get full details about what needs to be implemented to by compliant with Apple's framework. The URL below indicates that full BLE details should be explained in the "Nearby Interaction Accessory Protocol Specification" but we don't see any info there. https://developer.apple.com/documentation/nearbyinteraction/ninearbyaccessoryconfiguration https://developer.apple.com/nearby-interaction/specification/ Can someone indicate us where the find full details for this background Nearby Interaction feature? Thanks in advance. Regards.
Posted
by gorka-mk.
Last updated
.
Post not yet marked as solved
2 Replies
275 Views
I want to create a hands-free application (e.g. smart lock)using the Nearby Interaction framework. Nearby Interaction sessions can only be active when the app is in the foreground, however, it can't be a complete hands-free application. Does anyone have any good ideas?
Posted
by GPSMRI.
Last updated
.
Post not yet marked as solved
26 Replies
16k Views
I'm very excited about the new AirTag product and am wondering if there will be any new APIs introduced in iOS 14.5+ to allow developers to build apps around them outside the context of the Find My network? The contexts in which I am most excited about using AirTags are: Gaming Health / Fitness-focused apps Accessibility features Musical and other creative interactions within apps I haven't been able to find any mention of APIs. Thanks in advance for any information that is shared here. Alexander
Posted
by alexander.
Last updated
.
Post not yet marked as solved
2 Replies
520 Views
Can I use Nearby interaction to determine the location of 3 or more devices? I learned that by adding a session through the article below, I can interact with multiple devices. My question is, is it possible to make session A connect only with device A and session B only with device B? I've just started studying development, so I don't have a lot of knowledge. Thanks a lot for your help.
Posted Last updated
.
Post not yet marked as solved
1 Replies
478 Views
Hello, I recently experimented with the Nearby Interactions demo project for the U1/UWB chip. When using my iPhone 12 Pro and an Apple Watch Series 6 I was only able to go a distance of 16 feet before to connection would seem to break. Does anyone know if there is a way to utilize these chips to support calculating the distance between devices at a greater distance than what I was able to get?
Posted
by Coopered.
Last updated
.
Post not yet marked as solved
2 Replies
2.4k Views
HI 😊 I want to create MY OWN APP that will be able to communicate with my customized UWB devices ( UWB CHIP MOUNT ON ARDUINO / RASPERRY PI board or maybe can communicate with airtag / samsung tags /other third parties uwb tags ,too , but however my main purpose is , create my app that will be able to communicate with my customized UWB tag / devices , So I found out that the NEARBY INTERACTION framework that utilizing the UWB U1 CHIP of iphone 11/12 ,* does not provide the API CODE for this 😥 later on , Apple allows the app developer to only create their own UWB DEVICES / TAGs that will be able to communicate / utilize with iphone11/12 BUT ALL OF THE UWB CUSTOMIZED DEVICES / tags FROM THE DEVELOPERS ,-- MUST BE USED WITH ONLY THROUGH " * Find My ( APP ) *** " FROM APPLE under the app developer of Apple program , called * MFi * - MADE FOR IPHONE = https://mfi.apple.com/ -- under this program , * the developers can not create their own uwb app to utilize their own uwb devices/ tags as like me *😥 now there are some of third parties devices such as -Ebikes VanMoof S3 ,X3 model or Chipolo ONE Spot uwb tags or Belkin earbuds that joint MFI APPLE program , however all of them must be used with Find my app ( Apple ), ** they can not create their own app to utilize their own uwb devices So I do not know when will apple provide its uwb API for developers to create their own app to communicate with their own uwb tags / devices I want to create my own app that will be able to get the distance / direction from my uwb devices or maybe third parties devices too* but right now can not because of what I explained above ,in this Apple forum question so if Apple open the UWB API for the app developers access / develop their own ( using - UWB ) apps ,Apple will have more creative UWB apps from creative ideas of app developers So I am asking Apple ,-When will Apple provide the uwb API for the app developers to do such a things as my case ? PLEASE 🥺
Posted
by KEN158.
Last updated
.
Post not yet marked as solved
4 Replies
1.3k Views
Will the apple have the plan to support or interact with other UWB DEVICES ? for example iphone 11 can measure the distance between iphone 11 and other brand of UWB devices or third-party UWB devices , BECAUSE IF APPLE HAS the SUPPORT OF THE API FOR U1 chip OR IPHONE 11 TO INTERACT OR MEASURE THE DISTANCE WITH OTHER BRAND OF UWB DEVICES THAN ONLY IPHONE11 OR APPLE AIRTAG , I REALLY THINK THE APPLE DEVELOPERs WILL BE ABLE TO CREATE MANY OF CREATIVE APPs more and more ,when the apple allow the iphone 11 interact with other brand UWB THAN ONLY iphone 11 or apple airtag or only apple products I meant i just want to measure the distance between iphone 11 and the UWB anchor ( UWB arduino device ) or other brand of UWB anchor or many of various UWB- IoT devices I AM ONE OF APP DEVELOPERS , I PERSONALLY ASK THE APPLE TO CREATE THE UWB API THAT ALLOW THE IPHONE 11 INTERACT OR MEASURE THE DISTANCE BETWEEN IPHONE 11 AND OTHER BRAND OF UWB DEVICES OR ANCHOR AS ARDUINO so will the apple have the plan to support or interact with other UWB DEVICES soon ? when ?
Posted Last updated
.
Post not yet marked as solved
1 Replies
682 Views
Because of the 8 peer limit I'm using NWListener, NWBrowser, NWConnection, and Bonjour for up to 20 peer-to-peer concurrent connections. I followed this answer - https://developer.apple.com/forums/thread/652180 and this answer - https://developer.apple.com/forums/thread/661148 which are both from Apple engineers. The first one said to create multiple concurrent NISessions: All NISessions are peer-to-peer and as a result, creating multiple NISession objects is necessary to have multiple concurrent sessions. One approach is to create a dictionary between an identifier for the peer (i.e. a user identifier provided by your app MyAppUserID) and the NISession objects while also keeping track of the NIDiscoveryToken for each peer identifier:  var sessions = [MyAppUserID: NISession]() var peerTokensMapping = [NIDiscoveryToken: MyAppUserID]() And the second answer said to perform interactions with multiple iPhones: Create an NISession for each peer you would like to interact with. For example, if you are interacting with two peers, create 2 * NISession objects. Each NISession will have a unique NIDiscoveryToken associated with it. Share discovery token #1 with peer #1, and share discovery token #2 with peer #2. When you receive discovery tokens from peers #1 and #2, create 2 * NINearbyPeerConfiguration objects and use them to run sessions #1 and #2, respectively. The problem is when sending out a NIDiscoveryToken via NWConnection, I can't find a way to link to the NISession from the sent out data to the token that is received from the incoming data after I initialize a NINearbyPeerConfiguration object: eg. User object which is sent and received when other devices are discovered class User: NSObject, NSSecureCoding { 		var uid: String? 		var peerToken: NIDiscoveryToken? = nil 		init(uid: String, peerToken: NIDiscoveryToken) {...} 		// ... encoder for uid and peerToken 		// ... decoder for uid and peerToken } Send current user's NIDiscoveryToken data via NWBrowser and NWConnection and save it to the peerTokensMapping dictionary and save the session to the sessionsArr let currentUserId = "qwerty" var sessionsArr = [NISession]() var sessions = [String: NISession]() var peerTokensMapping = [NIDiscoveryToken: String]() func sendDataWhenNewDeviceIsDiscovered() { 		let session = NISession() 		session.delegate = self 		guard let myToken = session.discoveryToken else { return } 		let user = User(uid: currentUserId, peerToken: myToken) 		guard let outgoingData = try? NSKeyedArchiver.archivedData(withRootObject: user, 																														 requiringSecureCoding: true) 		else { return } 		let message = NWProtocolWebSocket.Metadata(opcode: .text) 		let context = NWConnection.ContentContext(identifier: "send", metadata: [message]) 		connection.send(content: outgoingData, contentContext: context, isComplete: true, completion: .contentProcessed({ [weak self](error) in             		if let error = error { return } 				self?.sessionsArr.append(session) 				self?.peerTokensMapping[myToken] = self!.currentUserId     		print("Successfully Sent") 		})) } Receive other user's NIDiscoveryToken data via NWListener and NWConnection. connection.receive(minimumIncompleteLength: 1, maximumLength: 65535) { 		[weak self](data, context, isComplete, error) in 		if let err = error { return } 		if let data = data, !data.isEmpty { 				self?.decodeReceived(data) 		} } func decodeReceived(_ data: Data) { 		guard let incomingData = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? User 		else { return } 		guard let uid = incomingData.uid, let peerToken = incomingData.peerToken 		else { return } 		let config = NINearbyPeerConfiguration(peerToken: peerToken) 		/* not sure what to do here to get the session that was created when the data was sent out */ 		for (key,_) in peerTokensMapping { 				if key.??? == peerToken.??? { 						session.run(config) 						self.sessions[currentUserId] = session 						break 				} 		} 		/* or try this but this is the other user's peerToken so this will never work */ 		for session in self.sessionsArr { 				if session.discoveryToken ?? "" == peerToken { 						session.run(config) 						self.sessions[currentUserId] = session 						break 				} 		} } Once the NINearbyPeerConfiguration is initialized how do I connect the incoming peerToken with the correct one that was sent out above that is currently inside the peerTokensMapping dict or the sessionsArr so that I can get the session and call session.run(config)
Posted
by lance145.
Last updated
.
Post not yet marked as solved
0 Replies
178 Views
Hi there, Im trying to use the Nearby Interactions, but when i do the import, XCode tells me that "File 'HomeViewController.swift' is part of module 'NearbyInteraction'; ignoring import" and when i want to create a NISession object it says that cant find NISession in this scope Any fix for this? Thank you
Posted Last updated
.
Post not yet marked as solved
0 Replies
271 Views
Hello All, I am facing one problem in the Nearby Interaction library, I want to connect multiple devices at the same time, Right now NISession is disconnect itself when a new device comes in range and connect with a new device My question is how can I connect with multiple devices at the same time and access the distance of all the connected devices. This how i am using right now final class NearbyInteractionManager: NSObject {   static let instance = NearbyInteractionManager()   var sessionNI: NISession?   weak var delegate: NearbyInteractionManagerDelegate?       func start() {     sessionNI = NISession()     sessionNI?.delegate = self     MultipeerConnectivityManager.instance.delegate = self     MultipeerConnectivityManager.instance.startBrowsingForPeers()   }         private var discoveryTokenData: Data {     guard let token = sessionNI?.discoveryToken,        let data = try? NSKeyedArchiver.archivedData(withRootObject: token, requiringSecureCoding: true) else {       fatalError("can't convert token to data")     }     return data   } } extension NearbyInteractionManager: MultipeerConnectivityManagerDelegate {   func connectedDevicesChanged(devices: [String]) {     print("connected devices changed \(devices)")   }       func connectedToDevice() {     print("connected to device")     MultipeerConnectivityManager.instance.shareDiscoveryToken(data: discoveryTokenData)   }       func receivedDiscoveryToken(data: Data) {     print("data received")     guard let token = try? NSKeyedUnarchiver.unarchivedObject(ofClass: NIDiscoveryToken.self, from: data) else {       fatalError("Unexpectedly failed to encode discovery token.")     }     let configuration = NINearbyPeerConfiguration(peerToken: token)     sessionNI?.run(configuration)   } } // MARK: - NISessionDelegate extension NearbyInteractionManager: NISessionDelegate {           func session(_ session: NISession, didUpdate nearbyObjects: [NINearbyObject]) {     delegate?.didUpdateNearbyObjects(objects: nearbyObjects, token: nearbyObjects[0].discoveryToken)   }       func session(_ session: NISession, didRemove nearbyObjects: [NINearbyObject], reason: NINearbyObject.RemovalReason) {}   func sessionWasSuspended(_ session: NISession) {}   func sessionSuspensionEnded(_ session: NISession) {}   func session(_ session: NISession, didInvalidateWith error: Error) {} } protocol NearbyInteractionManagerDelegate: class {   func didUpdateNearbyObjects(objects: [NINearbyObject], token: NIDiscoveryToken) } Any update will be very helpful full Thank you
Posted Last updated
.
Post not yet marked as solved
0 Replies
190 Views
Hi, My sample work fine with 2 sessions on simulators, but don't work between 2 devices (iPhone 11 Pro and iPhone 13 Pro), or one device and one simulator. (iOS 14) I get didInvalidateWith Error (Domain=com.apple.NearbyInteraction Code=-5884). I re-tried with new session on error, but don't work. Any suggestion? Thanks
Posted
by Droppix.
Last updated
.