I have an iOS application that downloads an 开发者_运维知识库xml file using:
NSURL *queryURL = [NSURL URLWithString:query];
NSData *xmlData = [[NSData alloc] initWithContentsOfURL:queryURL];
The call is made to a third-party, so I'm not in control of the servers. The third party needs to know what that user-agent is (they are optimizing the feed based on the user-agent)
My question is how can I determine what my user-agent is? I don't specifically set that anywhere and didn't find anything in the documentation.
The user-agent is undocumented and subject to change. If you want to control the user-agent header, you will need to use NSURLConnection
with an NSMutableRequest
. Apple's documentation has an example of how to use NSURLConnection
.
It has to do with the name of your app (bundle identifier). In the end I just wrote a quick method to call a web server I do have control of, launched the app, and then read the logs from that web server and I could see the exact user-agent information.
精彩评论