Open Links outside the App

About Paths - seems to be a small package with various utilities: https://github.com/aramk/meteor-utility/blob/master/src/Paths.coffee

Does a simple check only:

  isUrl: function(path) {
    return Types.isString(path) && path.indexOf('://') >= 0;

As of now, with Meteor 1.3 and cordova-plugin-inappbrowser@1.3.0, the below line seems to be enough to open links on both Android and iOS.

window.open(url, ‘_system’);

1 Like

its still not working on my side

Did you add the App.accessRule to your mobile-config.js file? Something like:

App.accessRule('http://*', {type: 'intent'});
App.accessRule('https://*', {type: 'intent'});
1 Like

I added type navigation, then it worked.

What was the final solution of this @julianmwagner? Could you share what you have done to get this working?

App.accessRule(’*’, { type: ‘navigation’ })

try this one

How to pass post params?

Sorry for bumping, but these events never seem to get fired, and the link just opens in the app itself. Does anyone have any idea what I could have done wrong, or maybe the method has changed with Meteor 1.6?

EDIT:
Attaching "click a" on Template.body worked after using the gwendall:body-events package from Atmosphere.

Modify mobile-config.js and add lines

App.accessRule('http://*', {type: 'intent'});
App.accessRule('https://*', {type: 'intent'});
App.accessRule('skype:*', {type: 'intent'})

Setting {type: 'intent'} asks the user which app to use for opening the link while {type: 'navigation'} opens the link in-app

1 Like

Hi, I’d like to give the choice on the same template between opening the same link http(s) either in app (1 link), or in external browser (2nd link). Is there a simple way to do this ?

Hi, this answer may come bit late but the question is still valid and this may help someone. I spent hours to get this done properly:

First, install Cordova InAppBrowser:

cordova plugin add cordova-plugin-inappbrowser

Then replace the window.open (this step is not necessary, but it makes things simplier)

window.open = cordova.InAppBrowser.open;

Then you can call:

<a href="https://google.com" onclick="window.open('https://google.com', '_system'); return false;">Google</a>

This will open Google in device’s browser. The return false; is important, otherwise the target URL will be opened in webview as well.

I have written more detailed blog article about the issue here

Using the inappbrowser no longer works for me.

Now, when I add the inappbrowser, I get the following error when building for iOS and Android:

While removing plugins                     
   cordova-plugin-compat,cordova-plugin-geolocation,cordova-plugin-meteor-webapp,cordova-plugin-splashscreen,cordova-plugin-statusbar,cordova-plugin-whitelist,cordova-plugin-wkwebview-engine
   from Cordova project:
   Cordova error: The plugin 'cordova-plugin-compat' is required by (cordova-plugin-geolocation), skipping uninstallation. (try --force if trying to update)

Removing the inappbrowser package results in a successful build.

A revelation, not needing cordova-plugin-inappbrowser.

iOS:

App.accessRule('http://maps.apple.com/*', {launchExternal:true});

Source:

Android:

	'click .js-open-video'(e) {
		var button = $(e.currentTarget);
		var url = button.attr("data-url");
		
		navigator.app.loadUrl(url, { openExternal:true });
	},
1 Like