[TIMOB-25485] iOS: Ti.Platform.openURL method always returns false on iOS
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | None |
Status | Closed |
Resolution | Done |
Resolution Date | 2018-08-08T08:43:25.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Motiur Rahman |
Assignee | Unknown |
Created | 2017-11-07T02:59:43.000+0000 |
Updated | 2018-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=objcTest 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
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.
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 usingcanOpenURL
instead. A proposed API would be:[~jquick] Does Android have something, too? An asynchronous solution should be important to not block the main-thread on this.
[~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.
[~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.