wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.59k stars 545 forks source link

onPressLink doesn't work in android #464

Open baotoan1905 opened 4 years ago

baotoan1905 commented 4 years ago

What react-native version are you using? 0.61.5 What react-native-pdf version are you using? 6.1.2 What platform does your issue occur on? (android/ios/both) Android - test in real device samsung note 8, android 9 Describe your issue as precisely as possible : 1) Steps to reproduce the issue or to explain in which case you get the issue

Join a screenshot or video of the problem on the simulator or device?

Show us the code you are using?

renderPdf() {
    const { resource } = this.state;
    return (
      <Pdf
        source={{ uri: resource.src, cache: true }}
        onError={error => {
          console.log(error);
        }}
        style={styles.pdfContainer}
        onPressLink={handleOnPressUrl}
      />
    );
  }
async function handleOnPressUrl(url) {
  console.log('url', url);
  const supported = await Linking.canOpenURL(url);
  if (supported) {
    // Opening the link with some app, if the URL scheme is "http" the web link should be opened
    // by some browser in the mobile
    await Linking.openURL(url);
  } else {
    Alert.alert(`Don't know how to open this URL: ${url}`);
  }
}
therveux commented 3 years ago

Same error for me using react-native 0.63.3 and react-native-pdf 6.2.2

Links inside PDF don't trigger onPressLink event

Some help would be appreciated

anatolyKhoronko commented 2 years ago

one year later... any update?

samihabuawadSL commented 1 year ago

it works for me having these setting on AndroudManfiest.xml

nikkizol commented 1 year ago

any update? it's still not working

  <queries>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="http" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="https" />
    </intent>
    <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:mimeType="*/*" />
    </intent>
  </queries>
nikkizol commented 1 year ago

@wonday

nikkizol commented 1 year ago

@samihabuawadSL I added:

 <intent>
     <action android:name="android.intent.action.VIEW" />
     <data android:scheme="http"/>
  </intent>

  <intent>
      <action android:name="android.intent.action.VIEW" />
      <data android:mimeType="*/*" />
  </intent>
</queries>

but no luck... is there anything else should be done?

nikkizol commented 1 year ago

all works, make sure links in pdf are set as hyperlinks - https://www.adobe.com/acrobat/resources/how-to-add-hyperlink-to-pdf.html

MuhammadRafeh commented 9 months ago

@nikkizol Do we still need to add intent?

MuhammadRafeh commented 9 months ago

Can anyone send his android manifest file?