wonday / react-native-pdf

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

HyperLinks on onPressLink is not working in IOS. #841

Open TajGoud opened 5 months ago

TajGoud commented 5 months ago

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={() => } onPressLink={uri => Linking.openURL(uri)} />

harrymash2006 commented 5 months ago

Any luck on this?

jasonxbliu commented 5 months ago

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
TajGoud commented 5 months ago

@jasonxbliu we are using the cli.

"react-native": "0.73.6",
"react-native-pdf": "^6.7.5",
"react-native-blob-util": "^0.19.9",
jasonxbliu commented 5 months ago

@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

SruthiVj commented 4 months ago

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

TajGoud commented 4 months ago

@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

andywall66 commented 3 months ago

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:

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.

apulk97 commented 3 months ago

Any luck in this?

haozxyz commented 3 months ago

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

adityacarnera commented 3 months ago

@haozxyz Works, thanks

andywall66 commented 3 months ago

Yep - that did it - thanks @haozxyz !

Moggieggwp commented 1 month ago

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

so it should be a patch with a fix?

andrewflo commented 1 month ago

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!

a-verma26 commented 1 month ago

@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!