Jacob Weber created CB-4330:
-------------------------------
Summary: handleOpenURL called twice in certain cases
Key: CB-4330
URL: https://issues.apache.org/jira/browse/CB-4330
Project: Apache Cordova
Issue Type: Bug
Components: iOS
Affects Versions: 2.9.0
Reporter: Jacob Weber
Assignee: Shazron Abdullah
I have an app with a custom URL protocol handler. If I load it via the custom
URL, it calls my handleOpenURL JS function, as expected. But if I then change
window.location.hash, and then load another URL in an iframe, handleOpenURL is
called again with the same URL.
1. Create an iOS project according to the docs
(http://cordova.apache.org/docs/en/2.9.0/guide_getting-started_ios_index.md.html#iOS%20Platform%20Guide)
2. Add this to the bottom of index.html, before the </body> tag:
{noformat}<button id="test">test</button>
<script type="text/javascript">
function handleOpenURL(url) {
console.log(url);
}
var test = document.getElementById('test');
test.addEventListener('click', function() {
window.location.hash = 'foo';
var frame = document.createElement('iframe');
frame.src = 'img/logo.png';
document.body.appendChild(frame);
}, false);
</script>{noformat}
3. Add this to the end of your HelloWorld-Info.plist file:
{noformat}<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.mycompany.myscheme</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sample</string>
</array>
</dict>
</array>{noformat}
4. Run the app.
5. Create a web page somewhere outside of the app, with a link like this:
{noformat}<a href="sample://page">(sample)</a>{noformat}
6. Open the page in Safari and click the link.
7. The app will open, and in XCode's console, you'll see "handleOpenURL:
sample://page".
8. Now click the "test" button in the app. This will change
window.location.hash, and create an iframe.
9. In XCode's console, you'll see a second "handleOpenURL: sample://page",
which shouldn't happen.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira