A temporary lib to handle the local network permission after iOS 14
$ npm install react-native-local-network-permission --save
$ react-native link react-native-local-network-permission
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-local-network-permission
and addRNLocalNetworkPermission.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNLocalNetworkPermission.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
import {checkLocalNetworkAccess,requestLocalNetworkAccess} from 'react-native-local-network-permission';
//you need to make sure the local network permission dialog popup once
await requestLocalNetworkAccess();
//then use checkLocalNetworkAccess when you need
await checkLocalNetworkAccess();
//here run the code depends local network access