gpt4 book ai didi

iphone - 如何在 iOS 上获取用户代理?

转载 作者:技术小花猫 更新时间:2023-10-29 10:29:49 25 4
gpt4 key购买 nike

在 iOS 上有没有办法获取设备的用户代理?我不想对其进行硬编码,因为我需要所有设备的用户代理,并且我需要将用户代理附加到 URL。

谢谢。

最佳答案

在 iOS 中确定用户代理的一种更简单的方法是使用对 this SO post 的接受答案直接从 UIWebView 获取它。 .引用该答案:

The solution was to create a UIWebView and then just use javascript to pull out the user agent.

UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString* secretAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];

关于iphone - 如何在 iOS 上获取用户代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8579019/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com