react-native-pdf
react-native-pdf copied to clipboard
onPressLink doesn't work in android
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 :
- Steps to reproduce the issue or to explain in which case you get the issue
- Open PDF from remote url, press on some of urls inside pdf content, nothing happens, no log, no event trigger
- Interesting
logs
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}`);
}
}
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
one year later... any update?
it works for me having these setting on AndroudManfiest.xml
<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>
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>
@wonday
@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?
all works, make sure links in pdf are set as hyperlinks - https://www.adobe.com/acrobat/resources/how-to-add-hyperlink-to-pdf.html
@nikkizol Do we still need to add intent?
Can anyone send his android manifest file?