Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23888] iOS 10: UIApplication openURL has been deprecated

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2018-05-15T23:59:49.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.3.0
ComponentsiOS
Labelsdeprecated, ios10, openurl
ReporterHans Knöchel
AssigneeHans Knöchel
Created2016-09-09T22:53:45.000+0000
Updated2018-05-15T23:59:51.000+0000

Description

iOS 10 deprecates the usual [[UIApplication sharedApplication] openURL:@"myurl"] with a new API. Replacement:
        if ([TiUtils isIOS10OrGreater]) {
            [[UIApplication sharedApplication] openURL:newUrl options:@{} completionHandler:nil];
        } else {
            [[UIApplication sharedApplication] openURL:newUrl];
        }
We need to replace it in certain places, but since it just has been deprecated, nothing will break.

Comments

  1. Hans Knöchel 2016-09-11

    To note: Of course the old version still work and we currently don't have any advantages in switching to the iOS10-method unless we expose the options to the public API. Putting this for 7.0.0 for now.
  2. Hans Knöchel 2018-01-20

    PR: https://github.com/appcelerator/titanium_mobile/pull/9759 Test_Case (no parameters, legacy behavior):
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
           title: 'Trigger'
       });
       
       btn.addEventListener('click', function() {
           Ti.Platform.openURL('http://google.com');
       });
       
       win.add(btn);
       win.open();
       
    Test-Case (all 3 parameters):
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
           title: 'Trigger'
       });
       
       btn.addEventListener('click', function() {
           Ti.Platform.openURL('http://google.com', {
             'UIApplicationOpenURLOptionUniversalLinksOnly': true
           }, function(e) {
             Ti.API.info('Success: ' + e.success);
           });
       });
       
       win.add(btn);
       win.open();
       
    Test-Case (only URL and options):
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
           title: 'Trigger'
       });
       
       btn.addEventListener('click', function() {
           Ti.Platform.openURL('http://google.com', {
             'UIApplicationOpenURLOptionUniversalLinksOnly': true
           });
       });
       
       win.add(btn);
       win.open();
       
    Test-Case (only URL and callback):
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
           title: 'Trigger'
       });
       
       btn.addEventListener('click', function() {
           Ti.Platform.openURL('http://google.com', function(e) {
             Ti.API.info('Success: ' + e.success);
           });
       });
       
       win.add(btn);
       win.open();
       

JSON Source