Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking.openUrl not always working #1

Open
danielmocan opened this issue Apr 25, 2019 · 2 comments
Open

Linking.openUrl not always working #1

danielmocan opened this issue Apr 25, 2019 · 2 comments
Labels

Comments

@danielmocan
Copy link
Contributor

I'm trying to open a link from the React Native app.
For this, I'm using Linking from react-native package.

The problem is that only sometimes opens the link. In other cases it does nothing.

I also change the <Text> component with a <TouchableOpacity> but its still the same issue.
The problem is not from the if check, because the url its always valid ( and to falsy )

Anyone else had the same issue, any ideas to fix this issue?

Code Sample

  handlerOpenLink = url => {
    if (url) {
      Linking.openURL(url);
    } else {
      Alert.alert( "some message" );
    }
  };

return 
   <View>
     <Text
        onPress={ () => this.handlerOpenLink(url)}
      >
        Open Link
      </Text>
   </View>
@emimuresan
Copy link
Contributor

Hi @danielmocan ! I'd recommend adding a catch:

   Linking.openURL(url).catch((err) => {
      console.warn(`An error occurred for ${url}`, err);
    });

to investigate further.

Note: if you have a mailto link that does not work in the simulator but works on a real device.

@danielmocan
Copy link
Contributor Author

It seems to work ok now, I changed the <Text> to <TouchableOpacity>.
Thanks for the mailto link tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants