react-native-permissions icon indicating copy to clipboard operation
react-native-permissions copied to clipboard

iOS14 - Local Network permission support

Open vasyl-i opened this issue 3 years ago • 18 comments

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

  • This repository is using Polar.sh so you can help prioritize & fund this issue.
  • The funding will only be unlocked once this issue is completed.
Fund with Polar

vasyl-i avatar Sep 15 '20 13:09 vasyl-i

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

zoontek avatar Sep 15 '20 15:09 zoontek

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

fernandesrenan avatar Sep 25 '20 14:09 fernandesrenan

@fernandesrenan Not really:

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

zoontek avatar Sep 25 '20 14:09 zoontek

@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?

fernandesrenan avatar Sep 25 '20 14:09 fernandesrenan

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

zoontek avatar Sep 25 '20 14:09 zoontek

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

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

jimji1005 avatar Oct 23 '20 00:10 jimji1005

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

voulgarakis avatar Jan 29 '21 16:01 voulgarakis

Same issue here

geroale avatar Apr 05 '21 14:04 geroale

@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?

mikehardy avatar Apr 05 '21 15:04 mikehardy

@vahutson resolve ?

MarinaAmy avatar Sep 21 '21 10:09 MarinaAmy

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

verybluebot avatar Dec 16 '21 09:12 verybluebot

Resolve?

astrahov avatar Feb 07 '22 11:02 astrahov

+1 for support this permission

zameschua avatar Feb 14 '22 05:02 zameschua

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

mikehardy avatar Feb 14 '22 11:02 mikehardy

+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 🙂

zoontek avatar Feb 14 '22 11:02 zoontek

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.

geraintwhite avatar May 18 '22 15:05 geraintwhite

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

mikehardy avatar May 18 '22 16:05 mikehardy

@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

elmcapp avatar Apr 14 '23 17:04 elmcapp