This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
openInApp
Matei Radu edited this page Mar 3, 2019
·
2 revisions
1.4.0
.
If you're still using this function, check Migrating from 1.x to 2.x in preparation for the next major release expected for June 2019.
-
url
: a valid HTTP or HTTPS url. -
settings
: Optional. ASettings
object with settings for each platform.
A Promise
that is rejected if url
is not a valid HTTP or HTTPS url.
openInApp
will, as you might expect, open the given url in the platform-appropriate in-app browser with the given settings applied (if any).
Settings provided to openInApp
do not persist across multiple invocations and are valid only for every single instance. However, these settings will be applied on top of any global settings configured via InAppBrowser.configure(settings)
.
import openInApp from "@matt-block/react-native-in-app-browser";
// Only url.
openInApp("https://www.wikipedia.org/").catch(error => {
console.log(error);
});
// With platform-specific optional settings.
openInApp("https://www.wikipedia.org/", {
android: {
//...,
},
ios: {
//...,
},
}).catch(error => {
console.log(error);
});
// Using async/await.
async onClickHandler() {
try {
await openInApp("https://www.wikipedia.org/");
} catch (error) {
console.log(error);
}
}