add a user-agent

Welcome! Forums Unity Plugins In-App Web Browser add a user-agent

This topic contains 4 replies, has 3 voices, and was last updated by Piotr Piotr 1 month, 3 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1295

    ogyme
    Participant

    Hi, thank you for your amazing plugin, I would like to add user-agent information in the browser, because on the analytics of my website the in-app navigator is shown as “Unknown” and that’s bother me ^^

    Is there an easy-way to do that and supported on both platforms ?

    Thanks

    #1417

    nbrindic
    Participant

    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.

    #1418
    Piotr
    Piotr
    Keymaster

    Could you create PR for a github repository with this API?
    I could give you an access. Just send me your github username.

    #1419

    nbrindic
    Participant

    Hey Piotr, it is nbrindic, and my email there is the one I have registered my account on this forum. Btw – does this plugin allow window.open javascript calls?

    #1430
    Piotr
    Piotr
    Keymaster

    Added you as a collaborator. Feel free to create PR for your functionality.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.