[
https://issues.apache.org/jira/browse/CB-7606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14310466#comment-14310466
]
Shazron Abdullah commented on CB-7606:
--------------------------------------
Took a look at Eddy's patch here:
https://gist.github.com/EddyVerbruggen/3edb9f33b29d26c79ec7
Looking at one of the comments, a fixed delay is still not optimal, because
modern vs older devices will behave differently.
Been trying to find the best solution that works in a deterministic way.
Talking to [~purplecabbage] - he thinks the best way to make this behave in a
deterministic manner is to tie it to cordova's deviceready event, and I agree.
{code}
NSString* jsString = [NSString
stringWithFormat:@"document.addEventListener('deviceready',function(){if
(typeof handleOpenURL === 'function') { handleOpenURL(\"%@\");}});", url];
[webView stringByEvaluatingJavaScriptFromString:jsString];
{code}
cordova duck-punches (no animals were hurt!) document.addEventListener to do
what it needs to do, so because of this, if deviceready has already fired, the
callback will fire right away -- so handleOpenURL will always be called.
I haven't tested this yet, but I will try this approach and report back. I'm
also testing Antonio's approach here:
https://issues.apache.org/jira/browse/CB-8028?focusedCommentId=14231236&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14231236
.. he reports it as working, but this depends on plugins being loaded before
the url is handled, so there might be timing issues there.
> handleOpenURL handler firing more than necessary
> ------------------------------------------------
>
> Key: CB-7606
> URL: https://issues.apache.org/jira/browse/CB-7606
> Project: Apache Cordova
> Issue Type: Bug
> Components: iOS
> Affects Versions: 3.5.0
> Reporter: Paul Kane
> Assignee: Shazron Abdullah
> Fix For: 3.8.0
>
>
> I'm not an Obj-C or Cordova programmer so bear with me.
> Let's say my app is running. Then I hop over to my mail app and click on a
> link (myapp://blahBlahBlah) that should open up my app. This works fine, the
> app opens, my own URL handler (in javascript) takes over, etc.
> However in Obj-C the view controller is -- incorrectly, I believe -- storing
> that scheme data (blahBlahBlah) in self.openURL (so that it can be picked up
> later in processOpenURL function, called during webView initialization).
> This isn't normally a problem, except when you move to a new page
> (window.href = "/new_page"), the webView initialization runs again and picks
> up the old (already-acted-upon) openURL variable. (it's then set to nil, so
> that it doesn't get acted upon a third time, fourth time, etc...).
> I might have some details wrong, but it should be fairly easy to walk through
> with a project-wide search for "openurl". Just seems like a slightly wrong
> logic-flow, which unfortunately is interfering with my app.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]