alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
763 stars 398 forks source link

Alerts Not Working in Share Extension #99

Open AndrewHenderson opened 6 years ago

AndrewHenderson commented 6 years ago

Hopefully, I'm messing up something very simple, but I can't seem to get React Native Alert working in the share extension.

Alerts work fine in my main app, but calling Alert.alert has no effect in the extension. Perhaps the API is not accessible on iOS within extensions.

I can't seem to find anyone else discussing/reporting this issue.

AndrewHenderson commented 6 years ago

I'm also finding that NetInfo.getConnectionInfo returns "unknown" for the connection type.

And NetInfo.isConnected is false despite having Wi-Fi and successfully making HTTP requests from the extension.

CGReinhold commented 6 years ago

Hey, @AndrewHenderson, do you have any updates on this?

I'm having the same issue using a simple Alert.alert('Test', 'Test'); when the app is run from the share-extensions.

I also noticed that ActionSheetIOS has the same issue. This example simple won't work on the extensions but work properly on the main app:

ActionSheetIOS.showActionSheetWithOptions({
  options: ['Cancel', 'Remove'],
  destructiveButtonIndex: 1,
  cancelButtonIndex: 0,
}, () => {});
AndrewHenderson commented 6 years ago

@CGReinhold I chose to avoid certain unavailable APIs in favor of React UI.

I went to submit a bug on React Native's repo: https://github.com/facebook/react-native/issues/new?template=bug_report.md. They require an MCVE, so I'd have to write that.

I submitted a question on SO: https://stackoverflow.com/questions/52048505/react-native-apis-unavailable-in-share-extension. Maybe we'll get someone from the RN team to reply.

djorkaeffalexandre commented 4 years ago

@AndrewHenderson I think this PR can make this works.. https://github.com/facebook/react-native/commit/2968450 :) I'll try soon on my fork of this library and can open a pull request here. Thanks.