EddyVerbruggen / Custom-URL-scheme

:link: Launch your Cordova/PhoneGap app by a Custom URL scheme like mycoolapp://
1.03k stars 367 forks source link

handleOpenURL() not working if target app is already opened!! #174

Open murliatdure opened 8 years ago

murliatdure commented 8 years ago

Can we force if target app is already opened?

murliatdure commented 8 years ago

handleOpenURL() doesn't gets triggered if the app is already running in background for ios and android also.

Any alternatives to support the same?

murliatdure commented 8 years ago

Any update on handleOpenURL() function call while app resume?

or forcefully call or alternative plugin for supporting the same?

spc16670 commented 7 years ago

This sounds similar to what I have reported - #229.

shamun commented 7 years ago

Same problem.

Same problem here. LaunchMyApp.js is never getting executed????????? which never executing handleOpenURL().

Who is executing the LaunchMyApp.js atleast?

shamun commented 7 years ago

On Android: this is never getting executed. https://github.com/EddyVerbruggen/Custom-URL-scheme/blob/master/www/android/LaunchMyApp.js

Aarbel commented 6 years ago

@murliatdure have you found a way to make it work ?

Aarbel commented 6 years ago

Ok i found a way to fix it :

I was using two times

document.addEventListener('deviceready', onDeviceReady, false)

and using this in the wrong one :

window.handleOpenURL = function (url) { 
        setTimeout(function() { 
            alert(url); 
        }, 0); 
    }; 

So be sure you don't have other listeners of deviceready that could break triggering handleOpenURL

rolinger commented 4 years ago

@Aarbel - could you clarify your answer please. Using ionic i have the following, however it only works if app is not running in the background, how do I get it to work if app is already open in background?

.run(function($ionicPlatform,$state,$rootScope,$q,$ionicPopover,apiService) {
  $ionicPlatform.ready(function() {

    window.handleOpenURL = function(url) {
      setTimeout(_ => {
        var parsed = new URL(url); 
        var search = parsed.search.substring(1);
        var inObj = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g,'":"') + '"}', function(key, value) { return key===""?value:decodeURIComponent(value) }) ;       
        if (parsed.pathname == "//l") {
          if (inObj.l == 1) {
            setDB("app_whipLogin",1) ;
            whipLogin = inObj ;
          }
        }
      }) ;
    }
}) ;