Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

webView.getUserAgent() and webView.userAgent are undefined on iOS

$
0
0

So basically I'm using a user agent so I can redirect titanium app users and non-titanium app users who browse my website to the right pages.

If I use Titanium.userAgent, this is fine except that user agent affects how the Facebook login looks on my website (it doesn't look that great). If I use the default user agent on iOS, the Facebook login looks great except it uses a browsers user agent so there's no way to tell if I'm on the Titanium App or not.

So I tried appending my custom string to the default webview user agent on iOS like so:

var TiWebViewExtension = require('com.ptrikutam.tiwebviewextension');
Ti.API.info("user agent: " + webview.getUserAgent() +  " user agent 2: " + webView.userAgent);
TiWebViewExtension.setWebViewUserAgent(Titanium.userAgent);
However the Ti.API.info returns: > user agent: undefined user agent 2: undefined >

I'm also seeing on my access logs the user agent is indeed undefined. So there's clearly a bug on iOS where I cannot get the default user agent for some odd reason.

If I use the default webview's useragent then the facebook login looks clean and smooth, but I can't tell the app apart from others.

How do I get the default webview useragent on iOS without it saying 'undefined' ? I'm using the TiWebViewExtension module to set the user agent, but I don't think it has any methods to get the user agent? I tried:

TiWebViewExtension.getWebViewUserAgent() but that returns undefined too.

The only user agent that doesn't return undefined is Titanium.userAgent but the Facebook login looks very bad when I use that user agent.

Android works fine though...


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>