chetan
chetan

Reputation: 174

Cordova inAppBrowser plugin issue in ios and blackberry

I am developing cordova application for BB10,android,iod,windows8.

within that i have requirement of opening url in default device browser.

for that i had used org.apache.cordova.inappbrowser plugin.

but after using that i came across problem of relaunching application once i back from browser. [problem in all platform except windows8]

so that i had used below solution,

jQuery(document).delegate('.external', 'click', function(e) {
        window.open(e.target.href, '_system', 'location=yes');
        e.preventDefault();
});

<a class="external" href="myUrl">Track Now</a>

with above solution, Android: it was working fine. Blackberry10 problem: Url is not opened in external browser it is only opened in app browser, IOS Problem: url is not working at all(when i click on link nothing happened).

So, any help from your side is really appreciated.

Upvotes: 4

Views: 1126

Answers (2)

chetan
chetan

Reputation: 174

Yeah below is the solution for my case. And its working fine in all android, BlackBerry10 and IOS platform.

resolving blackberry issue by adding blackberry invoke plugin.

function openBlackBerryBrowser(url) {
            function onInvokeSuccess() {
                alert("Invocation successful!");
            }
            function onInvokeError(error) {
                alert("Invocation failed, error: " + error);
            }
            blackberry.invoke.invoke({
                target: "sys.browser",
                uri: url
            }, onInvokeSuccess, onInvokeError);
    }
    if (window.device.platform.toLowerCase().indexOf('blackberry') > -1) {        
        jQuery(document).delegate('.external', 'click', function(e) {
            openBlackBerryBrowser(e.target.href);
        });
    } else {        
        jQuery(document).delegate('.external', 'click', function(e) {
            e.preventDefault();
            var ref = window.open(e.target.href, '_system', 'location=yes');
        });
    }

Hope this will help someone.

Upvotes: 4

manzapanza
manzapanza

Reputation: 6245

In my opinion is not necessary the use of jquery to do this. You could try something like this, but I tested only on Android and iOS:

In your controller:

$scope.openLink = function(url){
   window.open(url, '_system');
};

html:

<a href="#" ng-click="openLink('http://www.google.com')">www.google.com</a>

Let me know if works also on BB!

Upvotes: 0

Related Questions