cordova-plugin-inappbrowser not opening links from

2019-08-20 12:46发布

问题:

Search a lot, but not able to find the correct solution.

I am trying to open links from my app to default browser of my IOS device, 

but its not working. Its perfectly working with my android device.

  • My plugin is installed properly, ( i can see that in cordova plugin list on my app)

    followed are the syntaxes, which i have tried:

    window.open(this.href, '_system');

    window.open(this.href, '_blank', {closebuttoncaption: 'Close', toolbar: 'yes', 'location=yes'});

    window.open(this.href, '_blank', {closebuttoncaption: 'Close', toolbar: 'yes'});

    window.open(this.href, '_system', 'location=yes')

    same solution with cordova.InAppBrowser.open, this as starting syntax.

    along with that tried with controller function also

    link

    $scope.openInExternalBrowser = function (path) {

    var options = "closebuttoncaption=Close,toolbar=yes"; if($ionicPlatform.is('ios') == true){

    window.open(path, '_blank', {'closebuttoncaption': 'Close', 'toolbar':'yes', 'location=yes'});
    

    }else{ window.open(path, '_system', 'location=yes'); } }

So looking for some proper solution, which will work.

Thanks & Regards,

Sopo

回答1:

Finally, after lot of research and thousand of builds, this post helped me to solve the issue.

Reference link

with the help of "cordova-plugin-whitelist" plugin. You need to add "gap:" after default-src attribute, your CSP meta. => default-src gap: *;

Thanks StackOverflow.



回答2:

I simply use this for my project and confirm it's work

cordova.InAppBrowser.open('https://google.com','_self')