Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handleOpenURL not firing on iOS cold start #93

Open
dustinblanchard opened this issue Jun 24, 2015 · 37 comments
Open

handleOpenURL not firing on iOS cold start #93

dustinblanchard opened this issue Jun 24, 2015 · 37 comments

Comments

@dustinblanchard
Copy link

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.

@arulapj
Copy link

arulapj commented Jun 26, 2015

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

@xale76
Copy link

xale76 commented Jun 27, 2015

have you found a solution? I have the same problem

@Exilz
Copy link

Exilz commented Jul 7, 2015

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

@benjick
Copy link

benjick commented Jul 9, 2015

Same with Android 5.0.1

@EddyVerbruggen
Copy link
Owner

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.

@alexszilagyi
Copy link

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.

@martindrapeau
Copy link

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

@EddyVerbruggen
Copy link
Owner

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

@martindrapeau
Copy link

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...

@possan
Copy link

possan commented Sep 11, 2015

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...)

@xale76
Copy link

xale76 commented Sep 21, 2015

still not working @possan
is there any solution?

@EddyVerbruggen
Copy link
Owner

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

@xale76
Copy link

xale76 commented Sep 21, 2015

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

@EddyVerbruggen
Copy link
Owner

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

@xale76
Copy link

xale76 commented Sep 21, 2015

cordova cli?
4.1.2

@EddyVerbruggen
Copy link
Owner

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

@xale76
Copy link

xale76 commented Sep 21, 2015

where I can find this information?

@EddyVerbruggen
Copy link
Owner

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

@vhuerta
Copy link

vhuerta commented Oct 12, 2015

Same problem, someone fixed it?

@vhuerta
Copy link

vhuerta commented Oct 13, 2015

i got the same problem, someone solved it?

@EddyVerbruggen
Copy link
Owner

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

@vhuerta
Copy link

vhuerta commented Oct 13, 2015

Im using the 3.9.1 version

@EddyVerbruggen
Copy link
Owner

Can you share your code with me perhaps?

@vhuerta
Copy link

vhuerta commented Oct 13, 2015

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);
};

@EddyVerbruggen
Copy link
Owner

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

@Alexintosh
Copy link

Setting a 500 timeout worked for me.

@mmBs
Copy link

mmBs commented Nov 2, 2015

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

@Exilz
Copy link

Exilz commented Nov 2, 2015

@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...

@mmBs
Copy link

mmBs commented Nov 2, 2015

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

@jschonenberg
Copy link

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
Copy link

Applying this fix from @easym0de seems to fix the problem completely: #2 (comment)

Could this get implemented? Adding the used URL as a global variable seems like a decent fallback (or even default!). In contrary to the openURL-function you can actually rely on the window being defined.

@alexspeller
Copy link

Nothing here worked for me, but then I deleted this line and everything started working properly

It seems like the initial cold start handler calls too early but it resets the url to nil, so when the warm start handler is called afterwards there is no url. Not sure if this is a good solution or not but it works every time for both cold start and warm start

@wudongyang
Copy link

Nothing here worked for me too.

I fixed it with call the HandleOpenURLNotification after 0.5s in application:openUrl
It works for me now.

[self performSelector:@selector(delayHandleOpenUrlNotification:) withObject:url afterDelay:0.5f];

-(void)delayHandleOpenUrlNotification:(NSURL*)url
{
    // all plugins will get the notification, and their handlers will be called
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
}

@lorensr
Copy link
Contributor

lorensr commented Jan 20, 2016

Same happening to me on Cordova iOS 3.9. I imagine this would be fixed if getLastIntent was implemented for iOS (it was added in #126 as Android-only).

@northkode
Copy link

northkode commented Jul 1, 2016

happens to me too.. cold start does not fire.. running ios 3.9.1 and straight up cordova build no frameworks other then my own js framework for loading views.

could this be related to the fact that i am using the wkwebview plugin? warm start works.. cold start no go

@srameshr
Copy link

srameshr commented Oct 13, 2016

Me on IOS 4. Cold start does not seem to work.

index.html

`

<script> function handleOpenURL(url) { setTimeout(function() { window.localStorage.setItem("externalLoad", JSON.stringify(url)); }, 0); } </script> ` ```

@tavosansal
Copy link

I am using Ember and have found something interesting. I was not able to trigger the handleOpenURL method on a cold boot for the life of me. I created a blank ember app with ember-cordova and nothing. Then I created a blank cordova app and sure enough it works. So now I have discovered that when the app is being served locally (ember cdv:serve) the event will never trigger on a cold boot. But if you build the app with (ember cdv:build) and then run it, the event does trigger. So I am not entirely sure what the difference is or why this works, but thought I would share. If you are not using ember but still serving your app on your local machine somehow, this might be why you can't trigger that event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests