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

URL scheme no working #77

Open
hama opened this issue Nov 22, 2017 · 6 comments
Open

URL scheme no working #77

hama opened this issue Nov 22, 2017 · 6 comments

Comments

@hama
Copy link

hama commented Nov 22, 2017

i have added URL scheme , it was working on Safari browser, but not working on Sarariview, when click the link, nothing happened.

@hama
Copy link
Author

hama commented Nov 22, 2017

it was working , but must dismiss the SafariView .

@koenpunt
Copy link
Collaborator

If I understand correctly you managed to fix the issue yourself?

@sattaman
Copy link

This caught me too, probably should be made more obvious in docs, since when using Linking.openUrl ,
navigating to an internal link automatically closes the browser.

@aless10
Copy link

aless10 commented Oct 30, 2020

it was working , but must dismiss the SafariView .

Hi, I'm trying to do this, but I can't figure it out how.
I have a basic html page and I have a link that should return to the app via a Url Scheme.
This is the function I use to open the view

const onOpen = () => {
    SafariView.show({
      url: 'http://localhost:8000',
    })
      .catch(() => {
        // Fallback WebView code for iOS 8 and earlier
      });
  };

I don't understand how to trigger the dismiss event from the webpage.

@koenpunt
Copy link
Collaborator

koenpunt commented Nov 1, 2020

@aless10 you have to use the react Linking api to intercept your url scheme, and from there you can invoke SafariView.dismiss() to close the safari view.

@aless10
Copy link

aless10 commented Nov 2, 2020

Hi @koenpunt (thanks for the reply). So I guess I need to add this code inside the component?

const _handleOpenURL = (e) => {
    SafariView.dismiss()
  }

// Took this from an example on how to use Linking events
 React.useEffect(() => {
    Linking.getInitialURL().then((ev) => {
      if (ev) {
        _handleOpenURL(ev);
      }
    }).catch(err => {
      console.warn('An error occurred', err);
    })
    Linking.addEventListener('url', _handleOpenURL)

  }, []
  )

Consider that I have a link inside the page I'm opening that points to the application (eg myapp://). It works when I open the browser, but it does not work with the SafariView.
It looks like the Linking event handler does not work, but maybe I'm missing something here.
I think that when I manage to fix this I will open a PR to close this issue and add it to the documentation?

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

4 participants