zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
3.97k stars 821 forks source link

iOS14 - Local Network permission support #509

Open vasyl-i opened 3 years ago

vasyl-i commented 3 years ago

Feature request

Support for Local Network permission needed (iOS14)

Why it is needed

With iOS 14 user may disallow Local Network permission for mobile app, which will deny access for app to local devices. https://developer.apple.com/videos/play/wwdc2020/10110/

Possible implementation

Should be used like something like this:

    Permissions.getPermissionStatus('localNetwork').then((r) => {
        if (r === 'authorized') {
           // Do something
        } else if (r === 'undetermined') {
          Permissions.requestPermission('localNetwork').then((response) => {
              if (response === 'authorized') {
                           // Do something
              }
              if (response === 'denied') {
               // Notify user about Local Network permission denied, advice user to turn on permission
               }
            });
        } else {
               // Notify user about Local Network permission denied, advice user to turn on permission
        }
      });

Upvote & Fund

Fund with Polar

zoontek commented 3 years ago

@vahutson I'm not sure this is a requestable permission? I can't find any documentation about it on https://developer.apple.com/documentation/

fernandesrenan commented 3 years ago

idk if this helps: https://developer.apple.com/forums/thread/654916

zoontek commented 3 years ago

@fernandesrenan Not really:

I see this question has been asked on the forums already, and there is no API.

fernandesrenan commented 3 years ago

@fernandesrenan Not really:

I see this question has been asked on the forums already, and there is no API.

This means that no native API no feature on react-native-permissions?

zoontek commented 3 years ago

@fernandesrenan Totally. We are not wizards, Apple has to do its job.

jimji1005 commented 3 years ago

from Apple https://developer.apple.com/forums/thread/663858

How to trigger privacy permission https://developer.apple.com/forums/thread/663768

voulgarakis commented 3 years ago

is there a way to request user to allow Local Network permission in iOS 14?

geroale commented 3 years ago

Same issue here

mikehardy commented 3 years ago

@geroale doesn't look like an "issue" at this point, based on @jimji1005 comment it looks like it needs someone to implement it. Do you have PR you could propose?

MarinaAmy commented 2 years ago

@vahutson resolve ?

verybluebot commented 2 years ago

It seems that still there is not native api to trigger at this point (end of 2021) so this is not an issue can be handled directly here. But.. There is a hack around this.

For popping up the permission prompt: send a dummy request on your network which will prompt the pop.

Can be handled "manually" or it can be implemented as an api in react-native-permissions as an api so for the end user it will handle as all other library permission api's (Its a bit of a nasty hack, so guess its for the admins to decide)

Checking if Local Network permission is granted: This sill requite native code, but basically you will need to check the error type on connection fail and label it as Local Network. This will, require a PR as it not possible to do "manually" using only JS..

More in depth details about these solutions can be found in this SO answer - link

Personally Im going to write a small native library to perform these 2 hacks..

Can share the code for a PR to be added to this library if anyone is interested (I do write it in Swift though)

PS: All discussions I found about this issue on the native side are at the end of 2020, so maybe an api for these was added by now, if so I could not find such a thing.

Hope this helps

astrahov commented 2 years ago

Resolve?

zameschua commented 2 years ago

+1 for support this permission

mikehardy commented 2 years ago

@zameschua this is interesting, I think https://medium.com/hackernoon/i-thought-i-understood-open-source-i-was-wrong-cf54999c097b

zoontek commented 2 years ago

+1 for support this permission

Sure, we can hire my as a contractor to do it if you want. If all the people here ask their companies to get some funding, it should be possible 🙂

geraintwhite commented 2 years ago

I have a working solution which I am using in my app and I am interested in sharing it as a PR to this lib - the only caveat is that what I have is written in Swift, does anyone have any guidance on how to integrate it?

For reference, here is my implementation. It runs at app launch and currently just triggers the prompt without doing anything with the response.

mikehardy commented 2 years ago

That's pretty cool. I believe at this point every modern react-native project has already had to deal with the inclusion of swift files - I know I worked through tons of compilation issues with main repo in the 0.63/0.64 time frame and they should be all handled now

Stated differently: swift as a language should be valid for react-native modules

So then the question is whether you can easily include a single swift file in this module, and then wrap it as a separate cocoapods podspect to include for people, exposed in the typescript. Should be possible? Only way to know is to try I think

elmcapp commented 1 year ago

@grit96 I was looking at your pr and was wondering if it would be merged. If so do you have any idea approximately when? I tried to install the one from your PR on your fork but was not able to get it to install. Is there any chance you could create standalone version into we know if your pr is merged