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

ActionSheetIOS not working inside Share extension

Open Etienne-M opened this issue 5 years ago • 7 comments

Description

The following lines prevent using an action sheet inside of a Share App Extension on iOS. https://github.com/facebook/react-native/blob/v0.63.2/React/CoreModules/RCTActionSheetManager.mm#L62-L65

The thing that is really odd is that behind the scenes, the API provided by Apple for the Action Sheet is exactly the same as the one for the Alerts (it simply needs a different style parameter https://developer.apple.com/documentation/uikit/uialertcontroller), but the Alert works and the ActionSheet does not.

When I did the setup for the alerts to work inside of the Share App Extension, I had to do something like RCTUtilsUIOverride.setPresentedViewController(self) inside of our view controller used for the Share App Extension. Back when I did it, there was a validation that checked if there was an override of the view controller and then checked to see if it was inside of an app extension. I thought it was very neat. The code seems to have changed since then, but I wonder if the exact same validations could be made for the ActionSheet as they are done for the Alert since the latter can be used inside the Share App Extension, but not the ActionSheet although they both use the same UIAlertController.

React Native version:

    OS: macOS 10.15.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 1.20 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 11.6/11E708 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.7 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: 4.12.0 => 4.12.0
    react: 16.13.1 => 16.13.1
    react-native: 0.63.2 => 0.63.2

Steps To Reproduce

  1. Do the tedious setup of having a share extension in React Native because you love the library and believe in the vision;
  2. Be disappointed that you cannot use the action sheet.

Expected Results

Ideally, no longer dread my XCode console outputting Unable to show action sheet from app extension.

Etienne-M avatar Sep 02 '20 19:09 Etienne-M

Could you please create a PR to fix the issue, and improve React Native.

dulmandakh avatar Sep 05 '20 00:09 dulmandakh

Could you please create a PR to fix the issue, and improve React Native.

@dulmandakh I'd love too. I'm completely new to objective-C though, so don't expect the PR any time soon 😛 Where can I reach out if I need a hand understanding the choices behind the architecture? There's clearly some stuff that changed and I'd like my PR to fall in line with those decisions. Cheers!

Etienne-M avatar Sep 05 '20 22:09 Etienne-M

Hi @Etienne-M, appreciate the issue and investigation!

The commit that added the error was from 5 years ago https://github.com/facebook/react-native/commit/2f9bd1f62fb5a083fb6b29b0bb43197d48cca520, might be some time since the initial motivation.

Would removing that block be enough to enable the functionality you need?

safaiyeh avatar Sep 06 '20 01:09 safaiyeh

@safaiyeh Sorry about that, I remembered it working at some point and when I checked out older release tags, I couldn't find the whole directory, so I assumed the code was overhauled (which is a rookie mistake, the file was just moved). Regarding it working, my memory must have simply played tricks on me.

I won't straight up remove the check, it's there for a reason. I'll figure something out with that override I mentioned. Thanks for the follow-up. Cheers!

Etienne-M avatar Sep 06 '20 18:09 Etienne-M

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

stale[bot] avatar Dec 25 '20 17:12 stale[bot]

This issue isn't stale, there's a PR open for it, but no one is reviewing it 😞

Etienne-M avatar Feb 11 '21 18:02 Etienne-M

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 08 '23 05:07 github-actions[bot]