naoufal / react-native-safari-view

A React Native wrapper for Safari View Controller.

Home Page:https://www.npmjs.com/package/react-native-safari-view

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The .show() method not working on RN 0.48.X with Modal visible

dniccum opened this issue · comments

I just installed this package within my application. The .isAvailable() method works like a champ, however the .show() method does not work. Unfortunately I am not seeing any errors within my debugger either.

Can you share a code snippet?

This is the snippet that I am trying to use:

SafariView.isAvailable()
            .then(() => {
                console.log('is available');

                SafariView.show({
                    url: "https://google.com",
                    fromBottom: true
                })
            })
            .catch((error) => {
                Linking.canOpenURL(url).then((supported) => {
                    if (supported) {
                        Linking.openURL(url);
                    }
                })
            });
commented

maybe a stupid question, but did you run react-native link react-native-safari-view? @naoufal would be helpful to see this hint in readme 😊

@rssfeed Yes I have done this.

commented

Any outputs on Xcode console? Did you also try to omit "fromBottom" from show() method to test? Maybe also slightly adjust your code to console log error variable within the catch function.

@rssfeed I removed the show method as suggested with no luck. I did open the app with some logging enabled and I did receive this log entry within XCode:

Warning: Attempt to present <SFSafariViewController: 0x7f98abe87b90> on <UIViewController: 0x7f98abd208b0> whose view is not in the window hierarchy!

Suggestions?

Another follow up, if I attempt to launch the safari view controller from a simple view the component works fine with a few buttons. However if the view is somewhat more complicated, like within a Modal component for example, with multiple buttons, images and other layered content, I get the error above.

@rssfeed @naoufal I can confirm that this does not work if a Modal is present/visible.

@naoufal I have submitted a PR to fix this: #69

fixed with #53