analytics - User Agent in an iPhone App -
what default user agent if want add third party code (analytics or ads) in iphone app , how can change it?
change user-agent in header of request this:
nsstring* useragent = @"mozilla/5.0 (x11; u; linux i686; en-us; rv:1.8) gecko/20051111 firefox/1.5 bavm/1.0.0"; nsurl* url = [nsurl urlwithstring:@"http://www.stackoverflow.com/"]; nsmutableurlrequest* request = [[[nsmutableurlrequest alloc] initwithurl:url] autorelease]; [request setvalue:useragent forhttpheaderfield:@"user-agent"]; nsurlresponse* response = nil; nserror* error = nil; nsdata* data = [nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error]; nsstring *result = [[nsstring alloc] initwithdata:data encoding:nsasciistringencoding]; nslog(@"%@",result); get current user-agent / lookup user-agents specific browsers:
http://www.useragentstring.com/
the user-agent makes no difference.
use default one, or better, don't worry it.
Comments
Post a Comment