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

App Crashes on Page Load on IOS and Android #40

Closed
chakafasano88 opened this issue May 23, 2018 · 13 comments
Closed

App Crashes on Page Load on IOS and Android #40

chakafasano88 opened this issue May 23, 2018 · 13 comments

Comments

@chakafasano88
Copy link

chakafasano88 commented May 23, 2018

Getting an error Invariant Violation: Native component for "PDFView" dos not exist. I installed the package using yarn and my import is import PDFView from 'react-native-view-pdf.

I've also cleaned cache and rm -rf node_modules several times.

@chakafasano88 chakafasano88 changed the title App Crashes on Page Load on IOs and Android App Crashes on Page Load on IOS and Android May 23, 2018
@rumax
Copy link
Owner

rumax commented May 24, 2018

Did you link the library?

@rumax
Copy link
Owner

rumax commented May 25, 2018

@chakafasano88 do you still have this issue and need help? or it can be closed?

@chakafasano88
Copy link
Author

chakafasano88 commented May 25, 2018 via email

@morgandonze
Copy link

@chakafasano88 what was your solution? Please post!

@chakafasano88
Copy link
Author

chakafasano88 commented Aug 3, 2018

@mlaco
This caused much frustration but here is a solution !

I ended up using WebView a PDF viewer provided by React Native. It works with ease for IOS.
However there is a small modification to make this work with Android.

Create two variables: the first stores your url.
The second checks if the device is IOS or android(make sure to import Platform from RN) :

    const { url } = this.props.navigation.state.params;
    const uri =
      Platform.OS === "ios"
        ? url
        : `https://drive.google.com/viewerng/viewer?embedded=true&url=${url}`;

If not IOS, append your url to the google URL above.

Finally, insert the uri into the WebView

          <WebView
            bounces={false}
            scrollEnabled={false}
            source={{ uri: uri }}
            onLoadStart={() => this._showSpinner()}
            onLoad={() => this._hideSpinner()}
          />

That should do the trick !!

Let me know how it goes.

@indapublic
Copy link

I have same behaviour for IOS. Library is installed and linked (tried by automatic and manual).

@chakafasano88 Is it possible pass headers to Google Driver Viewer?

@rumax
Copy link
Owner

rumax commented Oct 4, 2018

@indapublic Can you, please, provide more detailed information, like can you reproduce it with demo project, what headers do you use, type of the PDF, resource (PDF document), logs, etc.?

Without knowing the reason and assistance in finding the issue we will not be able to fix the component, if it's the issue of the component.

@indapublic
Copy link

indapublic commented Oct 4, 2018

@rumax Exception will raise in any case (file/url with/without headers).
If my code contains <PDFView>, it will fall.

screen shot 2018-10-04 at 16 51 25

@indapublic
Copy link

Demo is working at the moment.
btw demo contains invalid link to old library ("react-native-view-pdf": "../react-native-view-pdf-0.4.1.tgz")

@sanderfrenken
Copy link
Collaborator

@indapublic can you please confirm the library is linked properly by checking in Xcode under your build's target -> General tab you see the library under the: Linked Frameworks and Libraries section.

In addition, if this does not suffice, you can look under your Build phases tab -> Target Dependencies, and add ReactNativeViewPDF here as well:

screen shot 2018-10-04 at 09 04 35

@indapublic
Copy link

screen shot 2018-10-04 at 17 20 27

Build Phases not contains any info about ReactNativeViewPDF

@indapublic
Copy link

Hm. And yes. I added to target dependencies and not I didn't receive any error in app.
Great! Thanks a lot!

@sanderfrenken
Copy link
Collaborator

@indapublic nice! Good luck with the rest of the work and please let us know in case of issues

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

No branches or pull requests

5 participants