Custom-URL-scheme icon indicating copy to clipboard operation
Custom-URL-scheme copied to clipboard

handleOpenURL not firing on iOS cold start

Open dustinblanchard opened this issue 9 years ago • 37 comments

I'm on Cordova 3.8.0 and my handleOpenURL function is not firing on a cold start of the app. It works fine if the app is already open, and works great on Android.

I'm assuming it's related to https://issues.apache.org/jira/browse/CB-7606.

dustinblanchard avatar Jun 24 '15 19:06 dustinblanchard

tried to change the version to 3.6.3, still its not working on IOS.

arulapj avatar Jun 26 '15 13:06 arulapj

have you found a solution? I have the same problem

xale76 avatar Jun 27 '15 09:06 xale76

Same problem here on Android 5.1 and possibly lower versions too.

Exilz avatar Jul 07 '15 13:07 Exilz

Same with Android 5.0.1

benjick avatar Jul 09 '15 14:07 benjick

If anyone can reproduce this problem with a vanilla cli generated project then I'd be more than happy to take a look. With something like Meteor in the mix you're on your own.

EddyVerbruggen avatar Jul 09 '15 15:07 EddyVerbruggen

I'm having the same issue with Ionic framework, tried different tips that I've found on web but none of them are working; my scenario throws this error: Failed to load webpage with error: Frame load interrupted.

alexszilagyi avatar Jul 16 '15 12:07 alexszilagyi

I am using cordova 4.0.0-dev and still have this issue. Any progress?

martindrapeau avatar Aug 27 '15 11:08 martindrapeau

@martindrapeau see my comment of July 9th. That offer still stands.

EddyVerbruggen avatar Aug 27 '15 14:08 EddyVerbruggen

Fair enough - I think we are all using frameworks and wrappers. Cocoon.io in my case. I will see what I can do and get back to you...

martindrapeau avatar Aug 27 '15 14:08 martindrapeau

As usual, adding a little delay solves the problem, at least for me...

function handleOpenURL(url) {
    setTimeout(function() {
        actuallyHandleOpenURL(url);
    }, 500);
}

function actuallyHandleOpenURL(url) {
...
}

(i'm on angular 1.3.13 / ionic 1.0.1 / react 0.13.3, lots' of 3's there...)

possan avatar Sep 11 '15 14:09 possan

still not working @possan is there any solution?

xale76 avatar Sep 21 '15 14:09 xale76

What's your setup like? The more details the better.

EddyVerbruggen avatar Sep 21 '15 14:09 EddyVerbruggen

I don't understand the question, sorry eddy :(

I build with Intel XDK cordova solution. It work for android, and not for iOS when the app is shut. Works when the app in in background. Setup is ipa

xale76 avatar Sep 21 '15 14:09 xale76

@xale76 You're describing the symptoms of an issue in Cordova-iOS 3.7.0 - which version are you using?

EddyVerbruggen avatar Sep 21 '15 14:09 EddyVerbruggen

cordova cli? 4.1.2

xale76 avatar Sep 21 '15 15:09 xale76

No Cordova-iOS, please check it and move to anything else than 3.7.0.

EddyVerbruggen avatar Sep 21 '15 15:09 EddyVerbruggen

where I can find this information?

xale76 avatar Sep 21 '15 15:09 xale76

I don't use XDK and please don't mistake me for Google :)

EddyVerbruggen avatar Sep 21 '15 15:09 EddyVerbruggen

Same problem, someone fixed it?

vhuerta avatar Oct 12 '15 22:10 vhuerta

i got the same problem, someone solved it?

vhuerta avatar Oct 13 '15 15:10 vhuerta

@vhuerta thanks for asking twice. What version of cordova-ios are you on? Not cordova-cli.

EddyVerbruggen avatar Oct 13 '15 15:10 EddyVerbruggen

Im using the 3.9.1 version

vhuerta avatar Oct 13 '15 15:10 vhuerta

Can you share your code with me perhaps?

EddyVerbruggen avatar Oct 13 '15 15:10 EddyVerbruggen

sure there is, im using Meteor but basically when i open the app from cold always im getting the index page

window.handleOpenURL = function handleOpenURL(url) {
    setTimeout(function() {
        if(Meteor.isCordova) {
            var host = window.location.protocol + "//" + window.location.host;
            if(url.indexOf('?external')) {
                Router.go(url.replace('saxmovil://', ''));
            }
        }
    }, 500);
};

vhuerta avatar Oct 13 '15 16:10 vhuerta

Ah Meteor again. Anything in the adb log or js console?

EddyVerbruggen avatar Oct 13 '15 16:10 EddyVerbruggen

Setting a 500 timeout worked for me.

Alexintosh avatar Oct 27 '15 11:10 Alexintosh

setTimeout does not work for me too. Does anybody have a different solution?

mmBs avatar Nov 02 '15 14:11 mmBs

@mmBs here is my modified meteor_cordova_loader. I put this in my-meteor-project/cordova-build-override/www/meteor_cordova_loader.js

https://gist.github.com/Exilz/3d50cf7614b982157faa

Cold start works like a charm on Android/iOS regardless of versions and phone's swiftness since it doesn't depend on timeout.

I guess it's quite risky for Meteor, though...

Exilz avatar Nov 02 '15 15:11 Exilz

@Exilz thanks for that. I will try to adapt this approach to my implementation - i use backbone.js

mmBs avatar Nov 02 '15 15:11 mmBs

I also HAD problems with handleOpenURL not being called on cold start. It worked fine on the iOS simulator but not on the actual device.

In my case I solved it by placing my handleOpenURL()-implementation in a script-element inside the body. Like so:

<body>
    <script type="text/javascript">
        function handleOpenURL(url) {
            setTimeout(function() {
                alert(url);
            }, 0);
        }
    </script>

    <!-- other html -->
</body>

On rare occasions it still doesn't work but I haven't been able to reproduce those bugs yet... This issue can also be merged with #2 imho.

(Oh, and @EddyVerbruggen, thanks for this awesome plugin!)

jschonenberg avatar Nov 04 '15 13:11 jschonenberg