Custom URL Scheme for Meteor/Cordova Apps

Anyone ever get custom URL schemes working in their Meteor App?

https://groups.google.com/forum/#!topic/meteor-talk/bQTWv_lmKYg

I’m having trouble getting this plugin to work, just thought I’d ask around.

1 Like

Did you solve it? Stuck with the same thing

1 Like

This is the version I am using (from my package list):

cordova:nl.x-services.plugins.launchmyapp  https://github.com/EddyVerbruggen/Custom-URL-scheme/tarball/3ce0b6df0eb7115114f11b448a99648825a8db13

I am using it like that and it works fine so far:

document.addEventListener('deviceready', function() {
    handleOpenURL = function handleOpenURL(url) {
        var url = url.replace("myapp://", "http://meteor.local/"); 
        Meteor.defer(function() {
            window.location.href = url; 
          });
     }
  });

@benjick I was able to get things to work, but I found that this plugin isn’t compatible with the WizCorp Facebook Plugin. The issue is actually a Cordova one where both apps try to add a custom url scheme to the iOS .plist file and only the first one gets it’s entry in. You can read about it here: https://issues.apache.org/jira/browse/CB-8007 The best thing to do in the meantime is to simply edit the .plist file manually before building in Xcode to add both the FB and the custom entry. Then things work fine.

I also found that sometimes the handleOpenURL function is called really fast, like before Meteor is ready to handle it, so I put this JS in the head of my page to store the url off of the window object that I check for when Meteor is ready

// Handle opening the native apps from a custom url scheme
if (window && !window.handleOpenURL) {
  function handleOpenURL(url) {
    if (window) window.invokeURL = url;
  }
}

Hi,
anyone managed to trigger the handleOpenURL function on a cold start (aka : when the app isn’t in background mode) ?
I can’t figure out how to do this, aside from that the plugin works great.

1 Like

Looks like it’s currently a bug when the plugin is used with Meteor. See here: https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/98

Has been fixed for Android, but iOS is still waiting.

FYI for anyone coming across this post, I got this working just fine with iOS and no hard-coded site url:

import {Meteor} from 'meteor/meteor';

Meteor.startup(() => {
  global.handleOpenURL = url => window.location.replace(url.replace('myappname://', '/'));
});

hi, @markoshust @MaximeB @benjick @alpjor

any achievement solved?

I need to do something similar open from the mobile app, a page say chrome or safari is possible is possible with Eddy Verbruggen’s library?

I’m going to check out Cordova’s universal links plugin. It looks much more advanced and supports deep linking out of the box.