Multipeer Connectivity

RSS for tag

Support peer-to-peer connectivity and the discovery of nearby devices using MultipeerConnectivity.

Multipeer Connectivity Documentation

Posts under Multipeer Connectivity tag

21 Posts
Sort by:
Post not yet marked as solved
0 Replies
198 Views
I understand that the Nearby Interaction framework is available on watchOS 8+, and I want to make a watch app that displays distance estimation between multiple watches (not iPhones) using UWB through Nearby Interactions. I see in the documentation that an iPhone can discover multiple device "discovery tokens" and create NISessions with them using the Multipeer Connectivity framework, but it looks like the Multipeer Connectivity framework is not available on watchOS? So, how might I make an independent watch app that can discover multiple nearby watches and setup NISessions with them? Thanks!
Posted
by milst.
Last updated
.
Post not yet marked as solved
1 Replies
211 Views
Since the Multipeer Connectivity framework no longer supports Bluetooth. (https://developer.apple.com/forums/thread/749346) Why does its official documentation still mention "In iOS, the framework uses infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks for the underlying transport." ?(https://developer.apple.com/documentation/multipeerconnectivity) What is the purpose of using Bluetooth personal area networks for the underlying transport?
Posted Last updated
.
Post not yet marked as solved
1 Replies
254 Views
Hello, In this inquiry(https://developer.apple.com/forums/thread/747860), I came across this conclusion. “Apple disabled TCP/IP networking over Bluetooth completely. Apple’s peer-to-peer networking APIs now run exclusively over Wi-Fi." I have three questions I would like to ask. The Multipeer Connectivity Framework supports Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks. Since the framework abstracts away the underlying protocols, we cannot specify which protocol to choose. Can this framework still establish a pure Bluetooth connection now? (Not just using Bluetooth for the discovery phase). Given that the framework supports Bluetooth protocols, why does it not require Bluetooth permissions but only local network permissions? Does the Bluetooth protocol supported by the framework have the capability to discover traditional Bluetooth devices and services that the Core Bluetooth framework can discover?
Posted Last updated
.
Post not yet marked as solved
0 Replies
224 Views
I've been recently working on a VisionOS app which uses CoreMl to identify specific body parts and display a window with information of the identified body part, since the use of Vision Pro's cameras is blocked, I'm using an iPhone to perform image classification, and then send the label to the headset using Multipeer Connectivity, I'd like to display a volume once the user selects a body part, could my iPhone return enough spatial information for me to be able to fully take advantage of Vision Pro's mixed reality capabilities?
Posted Last updated
.
Post not yet marked as solved
0 Replies
540 Views
Hello! We have an app that runs on two iPads, in two different modes, that communicate with one another using Apple's Multipeer Connectivity APIs. Last week, after upgrading to iPadOS 17.4 we have had MANY customer reports of erratic connectivity, only on iPadOS 17.4. The iPads connect for 30 seconds to a minute, disconnect, reconnect for a short time again, and repeat. Most of our customers are school districts who likely employee an MDM and we are working on verification of that in order to reproduce the issue in-house. Were there changes to the MPC framework in iPadOS 17.4 that could be causing sessions to be dropped? Are you aware of any interaction with device management software that could cause this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
235 Views
I would like to connect to a POS working with android system to send and receive data (JSON ). Is it possible to connect to the POS android device using peer to peer connectivity? Like wifi direct in andriod system ? Note that I don't want them to be on the same wifi network (eg. local wifi network) and send and receive through the network.
Posted
by AliAmer.
Last updated
.
Post not yet marked as solved
0 Replies
255 Views
Hi, to previse all of this, I am new to Swift and iOS app development. I have an Idea for an app, however, this includes Multiplayer connectivity for up to 10 people. I have been trying to look into what would be required to run this. I am confused if I need to invest in an external server or if I can run this through GameKit or CloudKit. Any help is appreciated. Thank you.
Posted
by TheOcter.
Last updated
.
Post marked as solved
1 Replies
425 Views
Hey devs! I recently started a project, a macOS app, which is like a Remote Desktop app but only on local network. For this I wanted to use the MultipeerConnectivity framework, and it's my first time using it. So I have already done the device discovery side that is working well as it is the easier part. Now I just need someone who knows how it works and who has time to explain me (as I couldn't find any documentation about this) how does work the OutputStream And InputStream in MC and if its a good choice for my needs. It has to be low latency and high resolution... I also have seen other frameworks such as WebRTC that I could combine with a local WebSocket Server, but as I'm new to live video streaming and that I don't know anyone that is experimented with this I wanted to ask there for your advices. Thank you in advance, TR-MZ (just an unknown Indie dev).
Posted Last updated
.
Post not yet marked as solved
0 Replies
428 Views
Hi everyone, I have an AR app that allows for collaborative sessions and synchronizes model state (e.g. rotation, can be changed via slider) using Multipeer Connectivity. The receiving peer parses the data and then uses DispatchQueue.main.async to update the UI (SwiftUI) and the model in SceneKit. Lately I have noticed that this synchronization seems to lag periodically. To analyze the issue better I compiled this minimal reproducible example: https://github.com/MrMuetze/MCSyncTest The repository includes a boiled down "Multipeer Connectivity" project that should make this issue reproducible on local devices (maybe even between one device and the simulator). I have also added a readme with a gif that shows the issue. The synchronization between devices worked like a treat for a long time but recently I have noticed that e.g. a rotation is not as smooth as before on the receiving device. A bit of debugging revealed that the messages are received quickly but then the work that needs to happen on the main thread is periodically delayed. In the example project the relevant code bit that should be executed on the main thread looks like this: func session(_: MCSession, didReceive data: Data, fromPeer _: MCPeerID) { print("received data") DispatchQueue.main.async { print("doing stuff") let doubleVal = data.to(type: Double.self) ?? 0.0 self.internalSliderValue = doubleVal self.sliderValue = doubleVal } } It updates a published variable sliderValue that is connected to a Slider and a Text UI element. Regularly (like every 500ms or so) the execution of work on the main thread seems to be delayed. After a short while all outstanding UI updates are executed at once which leads to visual stuttering. This can be observed by looking at the printed messages: ... received data <-- normal behavior doing stuff received data doing stuff received data doing stuff received data <-- hiccup starts received data received data received data doing stuff doing stuff doing stuff doing stuff received data <-- returns to normal behavior doing stuff received data doing stuff ... I have tried to change the "Quality of Service" to .userInteractive as well as limiting the number of messages that are sent in a certain timeframe (I tried one message every 100ms). Both changes have not helped and even with a much lower number of messages the periodic stuttering remains. Using DispatchQueue.main.sync is also not a solution right now. It does bring the sequence back into original order but the periodic "freeze" of the queue is prevalent there as well. This then leads to a "laggy" execution of what happened on the sending peer device. I am not very familiar with Profiling an app and using Instruments, but I have captured some timings in regards to the usage of the main thread and some backtraces. From what I can understand the workload of the written code should not be the issue, but rather an underlying system function or library. I can provide more information in regards to the backtraces if needed. Right now I can't really say what would be useful. Below is an image that shows the main thread usage at the very top. This happens when the slider lags as shown in the gif. I am working with Xcode 15.2 and run the app on iOS 17.3. For devices I use an iPad Pro (2nd gen.) and an iPhone 15 Pro. The issue happens in Debug as well as in Release mode. I can't quite say when the stuttering appeared initially. I wonder if anyone is aware of any changes to iOS or underlying frameworks that could have caused this issue. I am interested in any information about this, if the issue can be resolved or if I have to look for alternative workarounds. Let me know if I can add any additional information. Best regards! Bjoern
Posted
by MrMuetze.
Last updated
.
Post not yet marked as solved
0 Replies
362 Views
Hi all, hope everyone is well. I'm seeking clarification regarding AirDrop functionality in regards to apps. For example, can the new AirDrop function within iOS17, whereby putting two iPhones together transfers user contact details to one another be utilised by an app? If not, please could I have clarification what bluetooth functionality within iPhone's an App may be able to utilise and could an app connect to AirDrop API's in any way? If the new AirDrop feature is not currently able to be utilised by apps, is this likely to change in the future with upcoming iOS updates or is it a set in stone thing? Apologies, I don't have the deepest understanding of this topic and any help is really appreciated, thank you.
Posted Last updated
.
Post not yet marked as solved
0 Replies
404 Views
Hi everyone, I followed https://developer.apple.com/forums/thread/700295 to try to make sure one iPhone could perform UWB ranging with more than iPhone by creating a separate NISession for each phone and storing it in a dictionary, but I have not been able to get distance measurements from more than one phone at the same time. It seems that MPCSession allows all phones to see each other, but when it comes to UWB measurements, only 2 phones are able to exchange distance and angle measurements at the same time. It seems once an NISession starts working, it does not give other NISessions a turn to work. I set the MPC delegate to the same ViewController class, maybe that is the issue, but I have seen that Qorvo also set their Bluetooth connection delegate to the same class, and it works with their DWM3001CDK. Can you please help me make sure that each phone can receive distance and angle updates from multiple phones simultaneously?
Posted
by yerke5.
Last updated
.
Post not yet marked as solved
0 Replies
382 Views
The connection using MultipeerConnectivity between iPhones and iPads with iOS 17 or higher installed is not functioning. This issue was not observed on iOS 16 or earlier versions. Currently, when advertising from an iPhone, the iPad can detect the device, but the event handling to accept invitations on the iPhone is not being triggered correctly. Consequently, not responding to invitations is preventing the connection. While the Wi-Fi feature is enabled, previously, it was possible to establish connections without being connected to a specific Wi-Fi network. However, presently, connection seems to occur only when the iPad and iPhone are on the same network. Moreover, irregular connections are occurring between iPhones, yet there is no connection whatsoever between iPads and iPhones.
Posted
by XCAL.
Last updated
.
Post not yet marked as solved
0 Replies
415 Views
Hi everyone, I am trying on iOS 17.1.1 the Nearby Interaction framework and SceneKit. I am testing it on iPhone 15 Pro Max and iPhone 12 Pro Max. if NISession.deviceCapabilities.supportsDirectionMeasurement { print("Interact using device distance and direction.") } else if NISession.deviceCapabilities.supportsPreciseDistanceMeasurement { print("Interact using distance only.") } iPhone 12 Pro Max is working normally, but supportsDirectionMeasurement property in iPhone 15 Pro Max returns false and i cant use the SceneKit. Is anyone experiencing the same issue? Regards, Shin
Posted
by llshin.
Last updated
.
Post not yet marked as solved
2 Replies
501 Views
Hello Apple Support team, Steps tried out till now to resolve the scan issue for POS machines(Android Devices) in iOS 15.x: Changed UDP Listener’s Port Numbers according to the mentioned port numbers on Apple’s website. Checked the Network Framework provided by Apple for any related methods/properties that can resolve the issue. Updated the Deployment target from iOS 13.x to iOS 15.x for POSLib SDK in order to set the Network’s parameter attribution to the user so that networking performed using these parameters is directed to content specified by the user, not the developer. As per the R&D done till now, it appears the UDP connection is established properly and data is sent to the server but when we receive the data it is nil and also connection is cancelled. Thanks & Regards
Posted Last updated
.
Post not yet marked as solved
0 Replies
455 Views
Hello Apple Support Team, As per the business requirement, we have to communicate and exchange data chunks between applications running on iPhones and Android-based or Android phones through Bluetooth interface. We have achieved the requirement through IP/Wifi communication. We are trying to connect to Android and iPhone devices via Bluetooth through an iOS application. We carried out Bluetooth implementation using CoreBluetooth libraries. Below are the findings done by our development team: Core Bluetooth Library Implementation           Importing Core Bluetooth Library in BTConnectionManager class, which uses CBCentralManagerDelegate, CBPeripheralDelegate, CBCentralManager, CBPeripheral as peripheral, [CBPeripheral] array as peripherals array. Using the below methods: centralManagerDidUpdateState, centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber), centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral), peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?), peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: Service, error: Error?) we are able to scan and connect to BLE devices Findings: We were able to get the list of low-energy devices like Airpods, Earphones and Bluetooth music devices. But Not able to scan Bluetooth high-energy devices like PAX / Android Phones   Please suggest to us the approach to make the Android running devices listed through the Core Bluetooth library. Thanks & Regards
Posted Last updated
.
Post not yet marked as solved
0 Replies
557 Views
I am writing to seek assistance with a persistent issue I am encountering with Bluetooth pairing and Multipeer Connectivity on two iPad devices ((Model: [iPad Pro (11 inch,2nd generation)] and Model: [iPad (6th generation)) and running iOS [iOS 16.6] Issue Description: Bluetooth Pairing Problem: I am unable to establish a Bluetooth connection between two iPad devices. Despite following the usual steps for pairing devices, such as enabling Bluetooth and ensuring both devices are discoverable, the pairing process is not successful. This issue prevents the devices from communicating over Bluetooth. But when I try to pair these two iPads with different iPhone , Bluetooth pairing is successful. Multipeer Connectivity Issue: Additionally, due to the failed Bluetooth pairing, the Multipeer Connectivity framework on these devices is not functioning as expected. Multipeer Connectivity relies on Bluetooth and Wi-Fi for nearby device discovery and communication. As a result, my application, which relies on this framework, is unable to establish connections between the two iPad devices. Troubleshooting Steps Taken: I have attempted the following steps to resolve these issues: • Restarted both iPad devices. • Network resetting also done. • Ensured that Bluetooth is enabled on both devices. • Checked for any potential sources of Bluetooth interference. • Verified that both devices are running the latest version of iOS [16.6 version]]. • Attempted to forget and re-establish the Bluetooth pairing. Request for Assistance: Despite these efforts, the issues persist. I kindly request your guidance and support in diagnosing and resolving the Bluetooth pairing problem and the subsequent Multipeer Connectivity issues. These functionalities are critical for my application's functionality, and I would greatly appreciate your expertise in resolving this matter. If any additional information or diagnostic data is required to assist with the troubleshooting process, please let me know, and I will provide it promptly.
Posted
by Tiji_Joy.
Last updated
.
Post not yet marked as solved
4 Replies
929 Views
Hi! despite the documentation saying otherwise, MultipeerConnectivityService appears to be unavailable in visionOS. Am I missing something or is this an issue with the current beta or (hopefully not 😬) the documentation? https://developer.apple.com/documentation/realitykit/multipeerconnectivityservice do { entity.scene?.synchronizationService = try MultipeerConnectivityService(session: MultipeerSession.shared.session) print("RealityKit synchronization started.") } catch { fatalError("RealityKit synchronization could not be started. Error: \(error.localizedDescription)") } Xcode complains 'MultipeerConnectivityService' is unavailable in visionOS, while the scene's synchronizationService property can be accessed...
Posted
by RK123.
Last updated
.
Post not yet marked as solved
0 Replies
735 Views
I am having a video chat application using react js in the frontend and i have one SFU server which is based on Node js with WRTC library for supporting webRTC apis in the server side(M87). App.js import React, { useState, useRef, useEffect, useCallback } from "react"; import io from "socket.io-client"; import Video from "./Components/Video"; import { WebRTCUser } from "./types"; const pc_config = { iceServers: [ // { // urls: 'stun:[STUN_IP]:[PORT]', // 'credentials': '[YOR CREDENTIALS]', // 'username': '[USERNAME]' // }, { urls: "stun:stun.l.google.com:19302", }, ], }; const SOCKET_SERVER_URL = "https://192.168.132.29:8080"; const App = () => { const socketRef = useRef<SocketIOClient.Socket>(); ...... .......... const createReceiverPeerConnection = useCallback((socketID: string) => { try { const pc = new RTCPeerConnection(pc_config); // add pc to peerConnections object receivePCsRef.current = { ...receivePCsRef.current, [socketID]: pc }; pc.onicecandidate = (e) => { if (!(e.candidate && socketRef.current)) return; console.log("receiver PC onicecandidate"); socketRef.current.emit("receiverCandidate", { candidate: e.candidate, receiverSocketID: socketRef.current.id, senderSocketID: socketID, }); }; pc.oniceconnectionstatechange = (e) => { console.log(e); }; pc.ontrack = (e) => { console.log("ontrack success"); setUsers((oldUsers) => oldUsers .filter((user) => user.id !== socketID) .concat({ id: socketID, stream: e.streams[0], }) ); }; // return pc return pc; } catch (e) { console.error(e); return undefined; } }, []); ...... ............ return ( <div> <video style={{ width: 240, height: 240, margin: 5, backgroundColor: "black", }} muted ref={localVideoRef} autoPlay /> {users.map((user, index) => ( <Video key={index} stream={user.stream} /> ))} </div> ); }; export default App; server.js let http = require("http"); let express = require("express"); let cors = require("cors"); let socketio = require("socket.io"); let wrtc = require("wrtc"); const fs = require("fs"); let https = require("https"); const port=8080; const options = { key: fs.readFileSync("../cert/cert.priv.key"), cert: fs.readFileSync("../cert/cert.chain.pem"), }; const app = express(); const server = https.createServer(options, app); app.use(cors()); let receiverPCs = {}; let senderPCs = {}; let users = {}; let socketToRoom = {}; const pc_config = { iceServers: [ // { // urls: 'stun:[STUN_IP]:[PORT]', // 'credentials': '[YOR CREDENTIALS]', // 'username': '[USERNAME]' // }, { urls: "stun:stun.l.google.com:19302", }, ], }; const isIncluded = (array, id) => array.some((item) => item.id === id); const createReceiverPeerConnection = (socketID, socket, roomID) => { const pc = new wrtc.RTCPeerConnection(pc_config); if (receiverPCs[socketID]) receiverPCs[socketID] = pc; else receiverPCs = { ...receiverPCs, [socketID]: pc }; pc.onicecandidate = (e) => { //console.log(`socketID: ${socketID}'s receiverPeerConnection icecandidate`); socket.to(socketID).emit("getSenderCandidate", { candidate: e.candidate, }); }; pc.oniceconnectionstatechange = (e) => { //console.log(e); }; pc.ontrack = (e) => { if (users[roomID]) { if (!isIncluded(users[roomID], socketID)) { users[roomID].push({ id: socketID, stream: e.streams[0], }); } else return; } else { users[roomID] = [ { id: socketID, stream: e.streams[0], }, ]; } socket.broadcast.to(roomID).emit("userEnter", { id: socketID }); }; return pc; }; const createSenderPeerConnection = ( receiverSocketID, senderSocketID, socket, roomID ) => { const pc = new wrtc.RTCPeerConnection(pc_config); if (senderPCs[senderSocketID]) { senderPCs[senderSocketID].filter((user) => user.id !== receiverSocketID); senderPCs[senderSocketID].push({ id: receiverSocketID, pc }); } else senderPCs = { ...senderPCs, [senderSocketID]: [{ id: receiverSocketID, pc }], }; pc.onicecandidate = (e) => { //console.log(`socketID: ${receiverSocketID}'s senderPeerConnection icecandidate`); socket.to(receiverSocketID).emit("getReceiverCandidate", { id: senderSocketID, candidate: e.candidate, }); }; pc.oniceconnectionstatechange = (e) => { //console.log(e); }; ... ...... const closeReceiverPC = (socketID) => { if (!receiverPCs[socketID]) return; receiverPCs[socketID].close(); delete receiverPCs[socketID]; }; const closeSenderPCs = (socketID) => { if (!senderPCs[socketID]) return; senderPCs[socketID].forEach((senderPC) => { senderPC.pc.close(); const eachSenderPC = senderPCs[senderPC.id].filter( (sPC) => sPC.id === socketID )[0]; if (!eachSenderPC) return; eachSenderPC.pc.close(); senderPCs[senderPC.id] = senderPCs[senderPC.id].filter( (sPC) => sPC.id !== socketID ); }); delete senderPCs[socketID]; }; const io = socketio.listen(server); io.sockets.on("connection", (socket) => { socket.on("joinRoom", (data) => { try { let allUsers = getOtherUsersInRoom(data.id, data.roomID); io.to(data.id).emit("allUsers", { users: allUsers }); } catch (error) { console.log(error); } }); socket.on("senderOffer", async (data) => { try { socketToRoom[data.senderSocketID] = data.roomID; let pc = createReceiverPeerConnection( data.senderSocketID, socket, data.roomID ); await pc.setRemoteDescription(data.sdp); let sdp = await pc.createAnswer({ offerToReceiveAudio: true, offerToReceiveVideo: true, }); await pc.setLocalDescription(sdp); socket.join(data.roomID); io.to(data.senderSocketID).emit("getSenderAnswer", { sdp }); } catch (error) { console.log(error); } }); socket.on("senderCandidate", async (data) => { try { let pc = receiverPCs[data.senderSocketID]; await pc.addIceCandidate(new wrtc.RTCIceCandidate(data.candidate)); } catch (error) { console.log(error); } }); ..... ......... startServer(port); function startServer(port) { server.listen(port, () => { console.log(`[INFO] Server app listening on port ${port}`); }); }
Posted Last updated
.
Post not yet marked as solved
0 Replies
664 Views
How to create and handle multiple sessions using Nearby Interaction? It was briefly mentioned in the WWDC20 video titled "Meet Nearby Interaction" but I cannot find the implementation anywhere online. Can someone share sample code or point me towards the location where I can find the solution to this problem? Thanks.
Posted
by adokshaj.
Last updated
.
Post not yet marked as solved
0 Replies
1.1k Views
Hi, I'm a computer engineering student and I'm working on my end-of-degree project. For part of this project I need to be able to locate my position within a room of about 5x5m with an error of +-50cm. I think with the airtags placed at known locations like 3 corners of the room and with the distances to those 3 airtags it would be possible to triangulate my position with sufficient precision. For this I think I have to use the Nearby Interactions framework but I can't find how to work with airtags only with other iphones (Peer session) Could someone guide me?
Posted Last updated
.