Closed Princewil closed 1 month ago
Hello @Princewil! Method connectById
sends request if this device is browser, and sends accept for request if this device is advertiser:
From source code:
@override
Future<bool> connectById(String deviceId) async {
final result = _isBrowser.value
? await NearbyServiceIOSPlatform.instance.invite(deviceId)
: await NearbyServiceIOSPlatform.instance.acceptInvite(deviceId);
Sorry for the confusion, I would be glad if you can suggest an improvement to better understand this aspect!
Thanks for the response.
First, you are saying it's not a bug on why the advertising device don't get to see browsing devices??
Then secondly on your response for the connectById function. Assuming I have multiple devices as browsers how would the advertising device know the particular ID to use with the connectById callback to initiate a connections bearing in mind that these IDs are random values and can't be predetermined?
Thanks for the response.
First, you are saying it's not a bug on why the advertising device don't get to see browsing devices??
Then secondly on your response for the connectById function. Assuming I have multiple devices as browsers how would the advertising device know the particular ID to use with the connectById callback to initiate a connections bearing in mind that these IDs are random values and can't be predetermined?
@Princewil Ya, advertising device don't get to see browsing devices, it see only invitations from them It is Multipeer Connectivity logic https://developer.apple.com/documentation/multipeerconnectivity/mcnearbyserviceadvertiser
About connectById: For iOS, the execution logic can only be that the advertiser accepts the browsers invitation. That is, browsers first see the advertiser and call connectById. Only after that, the advertiser sees the list of invitations (peers). Accordingly, it calls connectById as a response to a specific invitation.
Thank you so much, it's well understood now I think this should be stated clearly on the readme file
Thanks once again for this wonderful package
@Princewil Thanks for writing here! If you have any ideas on how to improve the API, I'm open to suggestions!
Got it!💪
Question:
I've noticed an issue on iOS where devices set as Advertisers (
iOSNearbyService.ios?.setIsBrowser(value: false)
) are unable to see Browser devices (iOSNearbyService.ios?.setIsBrowser(value: true)
) via theiOSNearbyService.getPeersStream()
.According to the
iOSNearbyService.connectById(deviceId)
documentation:This suggests that when
connectById
is called, the Browser device sends an invite, and the Advertiser device needs to accept the invite for a connection to be established.My question is: Where can I find the callback function on the Advertiser device that handles the connection request from the Browser device?
A prompt response would be greatly appreciated as I am in the middle of a project. Thank you!
Your effort is appreciated 💗