react-nativelocal-network

check local network permission in react-native


I want to redirect users to the setting screen if they don't allow local network permission.

But not able to find any solution of the function which gets data about the allowed and disallowed status of local network permission.

I have tried a react-native-local-network-permission library but it's also getting error as below

TypeError: null is not an object (evaluating 'RNLocalNetworkPermission.check')

Let me know if we have any support for this issue or if we can detect the status of local network permission.


Solution

  • Neither React Native Autolinking or running npx react-native link react-native-local-network-permission works for this package. You have to follow the manual linking instructions.

    Manual installation - iOS

    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 add RNLocalNetworkPermission.xcodeproj

    In XCode, in the project navigator, select your project. Add libRNLocalNetworkPermission.a to your project's Build Phases ➜ Link Binary With Libraries

    Go to Project navigator > Libraries > [library name here].xcodeproj

    Click on Build Settings and then the first item under "Targets"

    Scroll down to 'Search Paths'

    Double click to edit the 'Header Search Paths'

    Add the following entry (click '+'): ${SRCROOT}/../../../ios/Pods/Headers.

    Make sure to set it to recursive.

    Clean (cmd + shift + K) and re-build (cmd + B)