Change User-Agent and remove App Name and defaults iOS

后端 未结 1 1311
傲寒
傲寒 2021-02-14 07:37

I am trying to change the User-Agent in iOS, however when I add my custom User-Agent it appends it to the existing User-Agent that contains my app name.

This is the code

1条回答
  •  伪装坚强ぢ
    2021-02-14 08:28

    To override the default user agent, use setValue:forHTTPHeaderField: instead of addValue:forHTTPHeaderField:. For example:

    [request setValue:@"MyUserAgent (iPhone; iOS 7.0.2; gzip)" forHTTPHeaderField:@"User-Agent"];
    

    0 讨论(0)
提交回复
热议问题