Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23553] Android: Ti.userAgent shouldn't be read-only

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2016-08-29T07:26:29.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsparity
ReporterChristopher Williams
AssigneeChristopher Williams
Created2016-06-23T22:10:57.000+0000
Updated2017-11-27T19:32:09.000+0000

Description

According to our docs, Ti.userAgent should be a property we can overwrite and should have a setter: http://docs.appcelerator.com/platform/latest/#!/api/Titanium-property-userAgent On Android that is not the case.
it('userAgent', function () {
		should(Ti.userAgent).be.a.String;

		var save = Ti.userAgent;
		Ti.userAgent = 'Titanium_Mocha_Test';
		should(Ti.userAgent).be.eql('Titanium_Mocha_Test');
		Ti.userAgent = save;
		should(Ti.userAgent).be.eql(save);
	});

Comments

  1. Chee Kiat Ng 2016-08-29

    It looks like the Ti.userAgent for Android is read only, as it is the equivalent of the Android System default user agent. The only useragent that you wish to set would be in webView, or the request header of HttpClient.
  2. Lee Morris 2017-03-20

    Closing ticket as invalid.
  3. Richard Lustemberg 2017-11-27

    I think you could also set the user agent on imageviews, and also in third party modules. You set the useragent globally, and all modules will be able to use (and modify) the shared value. In my use case, we are using middleware on an api to filter out all useragents except ours. We also append version numbers in case we want to enforce a client version.

JSON Source