Git Product home page Git Product logo

kleopatra999 / cordova-plugin-browsertab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google/cordova-plugin-browsertab

0.0 2.0 0.0 19 KB

A Cordova plugin that provides an interface to in-app browser tabs that exist on some mobile platforms, such as SFSafariViewController on iOS and CustomTabs on Android.

License: Apache License 2.0

CSS 11.74% HTML 7.31% JavaScript 23.82% Java 35.32% Objective-C 21.81%

cordova-plugin-browsertab's Introduction

cordova-plugin-browsertab

Note: This is not an official Google product.

About

This plugin provides an interface to in-app browser tabs that exist on some mobile platforms, specifically Custom Tabs on Android (including the Chrome Custom Tabs implementation), and SFSafariViewController on iOS.

Usage

To open a URL in an in-app browser tab on a compatible platform:

cordova.plugins.browsertab.openUrl('https://www.google.com');

This plugin is designed to complement cordova-plugin-inappbrowser. No fallback is triggered automatically, you need to test whether it will succeed, and then perform your own fallback logic like opening the link in the system browser instead using cordova-plugin-inappbrowser.

cordova.InAppBrowser.open('https://www.google.com/', '_system');

Complete example with fallback handling:

var testURL = 'https://www.google.com';

document.querySelector("#tabwithfallback").addEventListener('click', function(ev) {
cordova.plugins.browsertab.isAvailable(function(result) {
    if (!result) {
      cordova.InAppBrowser.open(testURL, '_system');
    } else {
      cordova.plugins.browsertab.openUrl(
          testURL,
          function(successResp) {},
          function(failureResp) {
            error.textContent = "failed to launch browser tab";
            error.style.display = '';
          });
    }
  },
  function(isAvailableError) {
    error.textContent = "failed to query availability of in-app browser tab";
    error.style.display = '';
  });
});

Building

Install Cordova if you haven't already:

npm install -g cordova

Then from the root directory:

cd demo
cordova platform add ios
cordova run ios
cordova platform add android
cordova run android

Development

During development if you want to make changes to the plugin you need to force a rebuild and add the plugin from source, like so (from the demo directory):

cordova plugin remove cordova-plugin-browsertab
cordova plugin add ../plugin

To refresh the platform build:

cordova platform remove ios
cordova platform add ios

To set breakpoints, etc, open the project in the code editor:

cordova platform add ios
open platforms/ios/BrowserTabDemo.xcworkspace

cordova-plugin-browsertab's People

Contributors

williamdenniss avatar airamrguez avatar prijindal avatar

Watchers

rosa maria palacios juncosa avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.