Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6426] MobileWeb: Add support for non-http protocols to Ti.Platform.openURL() and Ti.Platform.canOpenURL()

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2011-12-13T16:13:45.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2011-50, Release 1.8.0.1, Release 2.0.0
ComponentsMobileWeb
Labelsstage
ReporterChris Barber
AssigneeAnthony Decena
Created2011-12-01T16:05:05.000+0000
Updated2017-03-03T23:16:55.000+0000

Description

Ti.Platform.canOpenURL() just returns true for any and all urls. Ti.Platform.openURL() performs an window.open() for all URLs. For canOpenURL(), say true if url does NOT contain a ":" or it does contain a ":" but is http or https, otherwise false. It would also be nice to have checks for if running in a simulator, then blacklist known unsupported protocols. For example, iPhone simulator doesn't support mailto, tel, sms, itms, itms-apps. For openURL(), simply do something like: canOpenURL(url) ? window.open(url) : window.location = url; Problem with window.location is we may accidentally redirect the browser to a malformed mailto: or something. Perhaps we need to create a dummy iframe and target it by name with window.open()? Note: this needs to be tested on all browsers including devices (ios & android) and simulators.

Attachments

FileDateSize
platform_app.js2011-12-07T08:17:27.000+00002533

Comments

  1. Anthony Decena 2011-12-01

    The test for the ':' in the canOpenURL() function would fail on a url with no protocol but with a port, ie: someplace.com:8080 which would not be uncommon in a mobile web app. I'll try and come up with something that covers as much as possible while still remaining rather simple.
  2. Chris Barber 2011-12-01

    Also need to support :// which means use the current protocol.
  3. Chris Barber 2011-12-01

    I did some research and if you detect a URL that can be opened by local process (i.e. iTunes, mail, or something), it says to do it in a setTimeout:
       setTimeout(function () {
           window.location.href = url;
       }, 1);
       
    This is probably to allow the UI to refresh, perhaps in the event of a mouse up event on a button. You may want to checkout http://r.mzstatic.com/htmlResources/880B/web-storefront-base.jsz and http://r.mzstatic.com/htmlResources/880B/web-storefront-preview.jsz.
  4. Anthony Decena 2011-12-02

    I added a uri parser for the canOpenURL() method. I also fixed the issue where urls were getting incorrectly assigned to open in the current window. Commit is here: https://github.com/Mindelusions/titanium_mobile/commit/43764ed6634728de6960da5e7d903867eb0cf2d6 Test page is here: http://mindelusions.com/boneyard/ti_mobileweb/platform_url_test.html
  5. Lee Morris 2017-03-03

    Closing ticket.

JSON Source