naoufal / react-native-safari-view

A React Native wrapper for Safari View Controller.
https://www.npmjs.com/package/react-native-safari-view
494 stars 110 forks source link

SafariView works ok on simulator but doesn't work on physical devices. #65

Closed clucasalcantara closed 7 years ago

clucasalcantara commented 7 years ago

I've followed the instructions here and everything is ok and running on iOS simulator but when I try to run my app on the device it always fails.

openSafari = (url) => {
    SafariView.isAvailable()
    .then(SafariView.show({
        url,
        fromBottom: true,
        tintColor: "rgb(0,0,0)",
    }))
    .catch(() => {
        Actions.webViewModal({ url, onClose: this.closeLink })
    })
}
dswbx commented 7 years ago

What version of iOS do you have running on your physical device? Also, you could try to launch the app on a device in debug mode and adjust your catch function to log errors like so: .catch(error) => { console.log(error) /*...*/ }

koenpunt commented 7 years ago

What do you mean by "it always fails"? Do you get an error? Could it be that you try call open from a Modal? Because the current release doesn't work with modals, although a fix has been merged to master already (https://github.com/naoufal/react-native-safari-view/pull/53)

naoufal commented 7 years ago

@clucasalcantara If it works in the Simulator but not the device, I'd check the version of iOS running like @RSSfeed mentioned. Safari View controller is only supported on iOS 9+ devices.

I'm going to close this for now, but if you're still having the issue feel free to reopen it with the resulting logs of:

SafariView.isAvailable()
  .then(() =>
    SafariView.show({
      url,
      fromBottom: true,
      tintColor: "rgb(0,0,0)",
    }))
    .catch(console.log)