Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

InAppBrowser

Matei Radu edited this page Mar 3, 2019 · 7 revisions

Since release 1.4.0, importing InAppBrowser is the main way of consuming the library's API.

If you're still using the now deprecated functions, check Migrating from 1.x to 2.x in preparation for the next major release expected for June 2019.

Methods

Reference

InAppBrowser.open(url [, settings])

Parameters

  • url: a valid HTTP or HTTPS url.
  • settings: Optional. A Settings object with settings for each platform.

Return

A Promise that is rejected if url is not a valid HTTP or HTTPS url.

Description

open 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 open do not persist across multiple invocations and are valid only for each single instance. However, these settings will be applied on top of any global settings configured via InAppBrowser.configure(settings).

Examples

import { InAppBrowser } from "@matt-block/react-native-in-app-browser";

// Only url.
InAppBrowser.open("https://www.wikipedia.org/").catch(error => {
  console.log(error);
});

// With platform-specific optional settings.
InAppBrowser.open("https://www.wikipedia.org/", {
  android: {
    //...,
  },
  ios: {
    //...,
  },
}).catch(error => {
  console.log(error);
});


// Using async/await.
async onClickHandler() {
  try {
    await InAppBrowser.open("https://www.wikipedia.org/");
  } catch (error) {
    console.log(error);
  }
}
Clone this wiki locally