Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6561] Ti.Platform.openURL causes "undefined is not an object" error

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionDuplicate
Resolution Date2020-07-20T14:16:18.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsios
ReporterJustin Toth
AssigneeChristopher Williams
Created2020-06-18T00:29:50.000+0000
Updated2020-07-20T14:16:19.000+0000

Description

When launching any url with Ti.Platform.openURL on iOS, the app then throws this error:
[ERROR] Script Error {
[ERROR]     message = "undefined is not an object";
[ERROR]     type = TypeError;
[ERROR] } 
It does not provide a stack trace, which is a separate issue. The interesting thing is that it will actually execute the openURL command but then when you return to your Titanium app and execute any subsequent Titanium code, it throws the error. Another user has reported this same issue on [SO](https://stackoverflow.com/questions/62328830/getting-error-after-openurl-on-appcelerator-titanium-v-9), so I do not believe this issue is specific to our app. Below is a simple repro. Launch the app then wait 10 seconds and notice how it correctly opens the apple maps url. Return to the Titanium app and wait another 10 seconds, and notice how the second openURL errors. The second openURL isn't relevant, what is relevant is that Titanium code has executed after the first openURL, and that's enough to cause it to error.
var win = Ti.UI.createWindow({ 
	title: 'Ti.Platform.openURL Bug'
});
win.open();

var button = Ti.UI.createButton({
	top: 100,
	height: Ti.UI.SIZE,
	title: 'Open maps'
});
button.addEventListener('click', function() {
	Ti.Platform.openURL('http://maps.apple.com/maps?q=-8.012960,110.308998');
});
win.add(button);

setInterval(function() {
	Ti.Platform.openURL('http://maps.apple.com/maps?q=-8.012960,110.308998');
}, 10000);
Also of note, I'm not confident that the interval is the ONLY way to cause this error, as I get this error even executing openURL commands not in an interval, but it certainly is easier to reproduce if it is within an interval. This bug exists in Ti SDK 9.0.0+. Ti SDK 8.3.1.GA is the newest version that doesn't have this bug.

Comments

  1. Justin Toth 2020-06-19

    I found a workaround for now from another ticket, specifying the second and third args of openURL:
       Ti.Platform.openURL('http://maps.apple.com/maps?q=' + destinationAddress, null, () => { });
       
  2. Michael Gangolf 2020-06-26

    Workaround works fine! I had the same error opening a external URL in 9.0.3.GA
  3. Christopher Williams 2020-07-20

    Resolved as duplicate of linked ticket. Fix was just pushed to master/9_1_X/9_3_X. Release 9.1.0 will contain it. (or if you really need the fix and don't want to use the empty function callback workaround, you should be able to install a new 9_0_X branch build via ti sdk install -b. 9_0_X in about an hour once the build goes out)

JSON Source