Comments (9)
Ok great. Thanks for the confirmation. I was going to try that but worried that after a successful share the state of sharedContent would no longer be null, so I would then have to also check if it changes...
from react-native-share-menu.
-
I don't think it's needed... you could write that code directly in the Java module if you want: https://github.com/meedan/react-native-share-menu/blob/master/android/src/main/java/com/meedan/ShareMenuModule.java#L43. But then you would need to fork the module and it would work only for your specific case.
-
I think you should be able to call this in any component: https://github.com/meedan/react-native-share-menu/blob/master/example/index.android.js#L25
from react-native-share-menu.
Great. Thanks for the advice.
Do you know if it's possible to bounce into the app at a particular screen in the Navigation Stack rather than at the root of the Navigation Stack?
from react-native-share-menu.
You should be able to do that with react-navigation
, and navigate to a particular screen in the navigation stack when new shared text is received.
from react-native-share-menu.
Forgive the silly question, but I can't figure out how to use your getSharedText function to detect when there is NO shared text. The callback only fires when the function successfully finds text (or image), but if not, it returns out of the function without returning anything. Is there something I am missing about your logic? Thanks again for the help.
from react-native-share-menu.
I'm not sure I understand the question... how are you able to "share nothing"?
from react-native-share-menu.
Thanks a lot for the quick reply.
Apologies my question was unclear. Here's my use case:
Every time the home screen loads, I want to check for shared text in case the user is coming into the app via the Android share url button in chrome (for example). My problem is that when there is no share activity detected, ShareMenu.getSharedText immediately escapes and doesn't execute the if/else condition. Here is the code I am using in componentDidMount() ...
ShareMenu.getSharedText((text :string) => { if (text && text.length) { let comment = "empty comment" var share = { link: text, comment: comment } that.props.navigation.navigate ('AndroidShareScreen', { share: share }) } else { //if no share detected, go to login screen that.props.navigation.navigate ('LoginScreen') } }) */
I noticed this line in your ShareMenuModul.java file which means the behaviour I noticed is by design:
if(mActivity == null) { return; }
So, I'm wondering if it's possible to use your ShareMenu module to detect when there is NO share when the home screen loads (i.e. no intent, or activity)? Since getSharedText doesn't execute anything, or return anything when there is no intent detected, I can't figure out how to detect the case where there is NO shared text.
Thanks again!
from react-native-share-menu.
I suggest that you have the shared information in a state and populate the content there when there is shared content. When there isn't, the state will remain null
and then you can go to the login screen when the state is null
. Something like that below:
class Test extends Component {
constructor(props) {
super(props);
this.state = {
sharedContent: null,
}
}
componentWillMount() {
ShareMenu.getSharedText((text :string) => {
if (text && text.length) {
this.setState({ sharedContent: text });
}
})
}
componentDidMount() {
if (!this.state.sharedContent) {
// no share detected
}
}
}
from react-native-share-menu.
Please reopen if you still have problems.
from react-native-share-menu.
Related Issues (20)
- Share intent for multiple links crashing
- Issue While Building the app after installation HOT 2
- CustomView not opening for iOS
- ShareMenuReactView.continueInApp causes origin app to freeze
- Out of memory crashes are more frequent on iOS 17 when sharing certain URLs HOT 6
- Update example project
- Support "No Share Extension UI" flow on iOS HOT 2
- Add a privacy manifest for XCode 15
- Improve app group configuration for iOS
- Set up changelog format
- Do a test release HOT 1
- Ensure iOS share extension can load files of all types, from all apps
- Report content types more clearly (Android and iOS)
- Add a method to manage copied files on iOS
- Add support for the New Architecture
- v7.0 Tracking issue
- Anyone get this working with Expo? HOT 1
- Build failed HOT 2
- iOS: Skip / don't show dialog, jump into app directly HOT 1
- iOS app is not building with new architecture in react native 0.72.6 HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-share-menu.