react-native-pdf icon indicating copy to clipboard operation
react-native-pdf copied to clipboard

HyperLinks on onPressLink is not working in IOS.

Open TajGoud opened this issue 1 year ago • 14 comments

In the PDF package, hyperlinks are functioning correctly on Android, but the onPressLink functionality is not working as expected on iOS.

<Pdf source={ description.PrivacyPolicy } onLoadProgress={() => setLoading(true)} onLoadComplete={() => setLoading(false)} trustAllCerts={false} enableDoubleTapZoom={false} style={styles.pdfView} renderActivityIndicator={() => <CustomLoader />} onPressLink={uri => Linking.openURL(uri)} />

TajGoud avatar May 30 '24 07:05 TajGoud

Any luck on this?

harrymash2006 avatar Jun 10 '24 11:06 harrymash2006

Please make sure you have installed the right version of @config-plugins/react-native-blob-util,@config-plugins/react-native-pdf, react native pdf and RN.

image image

jasonxbliu avatar Jun 21 '24 02:06 jasonxbliu

@jasonxbliu we are using the cli.

"react-native": "0.73.6",
"react-native-pdf": "^6.7.5",
"react-native-blob-util": "^0.19.9",

TajGoud avatar Jun 21 '24 07:06 TajGoud

@jasonxbliu we are using the cli.

"react-native": "0.73.6",
"react-native-pdf": "^6.7.5",
"react-native-blob-util": "^0.19.9",

What is the version of expo and plugin? As the screenshot I posted, as you use the version of 6.7.5, the right version of expo is expo51. I have encountered the same issue and fixed it until I made all the related version compatible. You can check it again. @TajGoud

jasonxbliu avatar Jun 21 '24 09:06 jasonxbliu

I'm using the correct versions. But still facing the issue

SruthiVj avatar Jun 26 '24 12:06 SruthiVj

@jasonxbliu we are using the cli.

"react-native": "0.73.6",
"react-native-pdf": "^6.7.5",
"react-native-blob-util": "^0.19.9",

What is the version of expo and plugin? As the screenshot I posted, as you use the version of 6.7.5, the right version of expo is expo51. I have encountered the same issue and fixed it until I made all the related version compatible. You can check it again. @TajGoud

Am not using expo using cli version is 12.3.2 @jasonxbliu

TajGoud avatar Jul 15 '24 06:07 TajGoud

Same issue here. It seems to be an issue at the native level. The iOS implementation of this relies on the PDFViewWillClickOnLink of the delegate - whatever that means (I am not very familiar with underlying native patterns) - and it does not get triggered when I tap on a link. So far, I've put logs in a couple of places in the native code in RNPDFPdfView.mm, and am seeing:

  • Logging at notifyOnChangeWithMessage - which sends all messages to the JS side - is working
  • Logging at handleSingleTap - is working, firing every time I single-tap, whether over a link or not
  • Logging at PDFViewWillClickOnLink - is not working.

This is with: iOS 17.5.1 react-native 0.74.2 react-native-pdf 6.7.5 react-native-blob-util 0.19.9

And to be clear - I am not using Expo at all.

andywall66 avatar Aug 05 '24 15:08 andywall66

Any luck in this?

apulk97 avatar Aug 14 '24 06:08 apulk97

The problem actually already pointing out in that PR issue To totally remove this part

    // Disable built-in double tap, so as not to conflict with custom recognizers.
    for (UIGestureRecognizer *recognizer in _pdfView.gestureRecognizers) {
        if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) {
            recognizer.enabled = NO;
        }
    }

or set recognizer.enabled = YES will fix the issue

haozxyz avatar Aug 15 '24 00:08 haozxyz

@haozxyz Works, thanks

adityacarnera avatar Aug 16 '24 10:08 adityacarnera

Yep - that did it - thanks @haozxyz !

andywall66 avatar Aug 16 '24 13:08 andywall66

https://github.com/wonday/react-native-pdf/issues/841#issuecomment-2290175000

so it should be a patch with a fix?

Moggieggwp avatar Oct 08 '24 17:10 Moggieggwp

Hi I'm experiencing this same issue with Expo 51 and the required package versions instructed (https://github.com/wonday/react-native-pdf/issues/841#issuecomment-2181865334).

Confirmed that onPressLink is working correctly on Android. Is there a fix or workaround? Thanks!

andrewflo avatar Oct 19 '24 12:10 andrewflo

@haozxyz , recognizer.enabled = YES

worked for internal links within the PDF, but it doesn't function for external links. Is there a workaround to enable it for external links as well? Everything is working fine on Android; the issue seems to be only with iOS. External Hyperlinks here means, opening some webpage that are not within the app/pdf. say www.google.com Thanks!

a-verma26 avatar Oct 22 '24 17:10 a-verma26

The problem actually already pointing out in that PR issue To totally remove this part

    // Disable built-in double tap, so as not to conflict with custom recognizers.
    for (UIGestureRecognizer *recognizer in _pdfView.gestureRecognizers) {
        if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) {
            recognizer.enabled = NO;
        }
    }

or set recognizer.enabled = YES will fix the issue

Thanks @haozxyz!

NathanNovak avatar Dec 04 '24 16:12 NathanNovak

Hello everyone, I created a patch to properly disable double tap. This should solve the issue, until it will be fixed on main.

react-native-pdf+6.7.6.patch

cc @wonday

antonhudz avatar Mar 03 '25 13:03 antonhudz

Hello everyone, I created a patch to properly disable double tap. This should solve the issue, until it will be fixed on main.

react-native-pdf+6.7.6.patch

cc @wonday

thanks for this patch, this is working on simulators but when we are testing this on actual device it is not working RN Version => 0.73.2 RN PDF Version => 6.7.1

works on android perfectly

Subramanyarao11 avatar Mar 17 '25 12:03 Subramanyarao11

Hi 👋, thanks for working on this! Just wanted to confirm — has this fix been released in a new version of react-native-pdf yet, or is it still pending merge? Can someone confirm if this is resolved in the latest version, or should we manually apply the patch for now?

asad-SIddiq avatar Jul 03 '25 15:07 asad-SIddiq

Still having issues using external links on iOS with onPressLink; it just doesn't run

"expo": "~53.0.20", "react-native-pdf": "^6.7.7", "react-native-blob-util": "^0.22.2",

Iamsheye avatar Sep 16 '25 18:09 Iamsheye