PhoneGap: Open external link in default browser (outside the app)

前端 未结 16 1784
我在风中等你
我在风中等你 2020-12-09 15:36

I\'m trying to open links in Safari (on an iPhone) from a PhoneGap application. I\'m using PhoneGap version 3.1.0, and use PhoneGap Build, to build the application.

16条回答
  •  感动是毒
    2020-12-09 16:30

    Late answer but maybe it will be helpful for someone. So what I have in my working code in both iOS and Android application based on Cordova. To open external link in the default browser (Safari or Google):

    1) Make sure that you have inAppBrowser plugin

    cordova plugin add cordova-plugin-inappbrowser --save
    

    2) Add to device.js

    function openURL(urlString){
      let url = encodeURI(urlString);
      window.open(url, '_system', 'location=yes');
    }
    

    3) Create new link

    Go to Google
    

提交回复
热议问题