[TIMOB-23888] iOS 10: UIApplication openURL has been deprecated
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2018-05-15T23:59:49.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 7.3.0 |
| Components | iOS |
| Labels | deprecated, ios10, openurl |
| Reporter | Hans Knöchel |
| Assignee | Hans Knöchel |
| Created | 2016-09-09T22:53:45.000+0000 |
| Updated | 2018-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.
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.
PR: https://github.com/appcelerator/titanium_mobile/pull/9759 Test_Case (no parameters, legacy behavior):
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'); }); 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 }, function(e) { Ti.API.info('Success: ' + e.success); }); }); 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', { 'UIApplicationOpenURLOptionUniversalLinksOnly': true }); }); win.add(btn); win.open();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();