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

openInApp

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

⚠️ This function is deprecated since release 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.

Reference

openInApp(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

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).

Examples

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);
  }
}