Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does react-native-udp need changes for new iOS 14 Local Network Privacy? #139

Open
thibmaek opened this issue Oct 14, 2020 · 16 comments
Open

Comments

@thibmaek
Copy link
Contributor

With iOS 14 Apple introduced the new Local Network Privacy feature which prompts users first that an application wants to interface with devices on the local network.

For now, we are not seeing any prompt with react-native-udp although we're interfacing with the local network by performing device discovery, sending a datagram to the broadcast address of a router (255.255.255.255).

It seems weird that when we interface with UDP at this network level we would not see the prompt. Is this something that needs to be added to react-native-udp?

@thibmaek
Copy link
Contributor Author

Also see this issue thread on the CocoaAsyncSocket repository which react-native-udp uses under the hood.

@Rapsssito
Copy link
Collaborator

@thibmaek, thanks for the feedback! I don't know if this might be a CocoaAsyncSocket issue or react-native-udp must also update the iOS code. Sadly, I cannot test any iOS 14 device at the moment.

CocoaAsyncSocket is written in Objective-C and it is starting to show multiple deprecation warnings when compiling. I might have to look for another library for the long run. This problem might be fixed by switching to another iOS socket library.

If you find any more relevant info, please post on this issue!

@bitcrumb
Copy link

Hi, I'll just leave this here, as this contains extremely useful information by an Apple employee concerning the new "Local Network Privacy" behavior:
https://developer.apple.com/forums/thread/663858

@pedrodlz
Copy link

pedrodlz commented Feb 8, 2023

Any update on this?

@rt012
Copy link

rt012 commented Apr 15, 2024

somebody is using this package for ios? is there anything we have to consider?

@bitcrumb
Copy link

@rt012 As far as I know, Apple performed some fixes by now, which makes sure that the local network permission alert is properly triggered when using UDP. Apart from that, there's nothing special to take care of.

@ly678910
Copy link

hi, author!
I also had the same problem in ios 14+. I obtained the Local Network permission and applied for the Multicast permission. but app can not send message and can not receive message. Have you fixed the problem?Where's the other iOS socket library to replace the react-native-udp?

@ly678910
Copy link

@Rapsssito Can you answer my question?

@gibo77
Copy link

gibo77 commented May 19, 2024 via email

@ly678910
Copy link

Hi, Were you able to make it work it before on different version?

I do not try other versions,only use 4.1.7 the latest version

@gibo77
Copy link

gibo77 commented May 19, 2024 via email

@ly678910
Copy link

@gibo77 I first try to use it

@gibo77
Copy link

gibo77 commented May 19, 2024 via email

@ly678910
Copy link

My ios14+ problem is solved,for ios 14+,first "info.list" add the "NSLocalNetworkUsageDescription " permission. This code "socket.setBroadcast(true)" must be executed delay 500ms later. This allows you to send and receive udp messages. The code is organized as follows:

import dgram from 'react-native-udp'

const socket = dgram.createSocket('udp4')
socket.bind(12345)
socket.once('listening', function() {
setTimeout(() => {
udpSocket.setBroadcast(true); // this is pivotal,enable ios broadcast
socket.send('Hello World!', undefined, undefined, remotePort, remoteHost, function(err) {
});
}, 500);

})

socket.on('message', function(msg, rinfo) {
console.log('Message received', msg)
})

@ly678910
Copy link

My ios14+ problem is solved,for ios 14+,first "info.list" add the "NSLocalNetworkUsageDescription " permission. This code "socket.setBroadcast(true)" must be executed delay 500ms later. This allows you to send and receive udp messages. The code is organized as follows:

import dgram from 'react-native-udp'

const socket = dgram.createSocket('udp4') socket.bind(12345) socket.once('listening', function() { setTimeout(() => { udpSocket.setBroadcast(true); // this is pivotal,enable ios broadcast socket.send('Hello World!', undefined, undefined, remotePort, remoteHost, function(err) { }); }, 500);

})

socket.on('message', function(msg, rinfo) { console.log('Message received', msg) })

Destroy pages Remember to turn off the broadcast,excute code "socket.setBroadcast(false);"

@ly678910
Copy link

for android, Don't use the code "udpSocket.setBroadcast(true);"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants