Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:42:09+00:00 2026-05-29T07:42:09+00:00

I have a webview app tool, which essentially consists of the webview and two

  • 0

I have a webview app tool, which essentially consists of the webview and two buttons on a toolbar. One button to view the source of the page, and another button to view/change the current User Agent.

I have both functions working on iOS 5 (view source, and change User Agent), but I cant seem to grab the User Agent in iOS 4.x.

I’m using the following now:

userAgentViewController.UAText = [self.webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];

This works in iOS5, but in iOS 4.x, it doesnt return anything. Is there a way to achieve the same functionality in iOS 4.x?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:42:11+00:00Added an answer on May 29, 2026 at 7:42 am

    to get the useragent, check the HTTP header in the NSURLRequest of your response.
    You can retreive this one in the webViewDidFinishLoad delegate method.

    - (void)webViewDidFinishLoad:(UIWebView *)webView {
        NSLog(@"%@", [[webView request] valueForHTTPHeaderField: @"User-Agent"]);
    }
    

    to set it, you have to custom an NSMutableURLRequest and give it to your webView

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:@"yourwebsite.com"]];
    [request setHTTPMethod:@"POST"];
    [request setValue:USERAGENT_STRING forHTTPHeaderField: @"User-Agent"];
    [webView loadRequest:request];
    [request release];
    

    and that’s it !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iPad split-view app. The detailview is a webview. In which method,
Cocoa app, SnowLeopard I have a WebView in to which I'm loading HTML (essentially
I have an app which i want to open a webview right now i
In my app I have the WebView which shows html files. So I want
I have an app in which I have a WebView where I display some
I have an iPad app that contains a webview. The webview's page has a
I have a Universal app with a webView which resize when an orientation change
I have a WebView in my android app from which a lot of javascript
I've created an online store within an android app in webview but have one
In my project (iPhone app) I have a nice webview to allow users to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.