Welcome! › Forums › Unity Plugins › In-App Web Browser › add a user-agent › Reply To: add a user-agent
I have purchased this plugin and I have to say it works quite well on both iOS and Android.
But there is just one thing I miss, and it is very important for my app – I have to support “Login with Google”, which requires user agent properly set to some value.
It is trivial to add in your plugin:
Android:
———————————-
webview.getSettings().setUserAgentString(MyUA);
iOS:
——————-
// get original UserAgent string by using temporal UIWebView
UIWebView *tmp = [[UIWebView alloc] init];
NSString *originalUA = [tmp stringByEvaluatingJavaScriptFromString:@”navigator.userAgent”];
// create custom UserAgent string
NSString *customUA = [NSString stringWithFormat:@”%@ %@”, @”MY_CUSTOM_USER_AGENT”, originalUA];
// set custom UserAgent as default
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:customUA , @”UserAgent”, nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
After these lines, you could just expose a configuration field in Unity, and it will work.
This is pretty important feature for me, and I am willing to help kokosoft with it, so please reach me in order to do this thing.