Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25485] iOS: Ti.Platform.openURL method always returns false on iOS

GitHub Issuen/a
TypeStory
PriorityNone
StatusClosed
ResolutionDone
Resolution Date2018-08-08T08:43:25.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMotiur Rahman
AssigneeUnknown
Created2017-11-07T02:59:43.000+0000
Updated2018-08-08T08:43:31.000+0000

Description

[openURL](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Platform-method-openURL) method can open the URL but it returns false. It should return true

Testing Environment:

iOS Device version v11.0.3 Ti SDK 6.3.0 It seems deprecated natively for (iOS 2.0–10.0) - https://developer.apple.com/documentation/uikit/uiapplication/1622961-openurl?language=objc

Test Code

function doClick(e) {
	var success = Ti.Platform.openURL('http://my.jbhunt.com/c/document_library/get_file?p_l_id=26083956&folderId=27970378&name=DLFE-207201.pdf');
	Ti.API.info('success: ' + success);
}

$.index.open();

[INFO] :   success: false
[INFO] :   success: false
Thanks

Comments

  1. Victor Vazquez Montero 2017-11-07

    Customer has also said that it affects previous SDK versions. The link will open but return the status as failed. So when the user returns to the app the app thinks the link failed.
  2. Hans Knöchel 2017-11-07

    We would be able to add the native openURL:options:completionHandler: API as a new feature in upcoming versions of the SDK. In either case, checking if a URL can be opened should be done using canOpenURL instead. A proposed API would be:
       Ti.Platform.openURL('my_url', function(e) {
         if (!e.success) {
           Ti.API.error('Error opening URL!');
         }
       });
       
    [~jquick] Does Android have something, too? An asynchronous solution should be important to not block the main-thread on this.
  3. Joshua Quick 2017-11-07

    [~hknoechel], there's no equivalent to this on Android that I'm aware of. You're only option is to call queryIntentActivities(), which is the closest equivalent to canOpenURL() on Android. You then call Context.startActivity() (which we do for Ti.Platform.openURL()) and hope that the query didn't lie to you. Although the OS will display an alert stating that an app for the intent wasn't found in such a case, but there's no feedback to the code when this happens.
  4. Joshua Quick 2017-11-08

    [~morahman], the canOpenURL() function determines if the URL "scheme" can be opened. It should return true for your "http://" case because the Safari browser accepts "http:" schemes. It won't check if the website is valid because that can only be done by the web browser via an asynchronous HTTP request. You typically use canOpenURL() with custom URL schemes registered by installed apps, such as "twitter:" for the Twitter app and "comgooglemaps:" for Google Maps on iOS.

JSON Source