What is the User Agent string for Apple TVs running tvOS?
Asked Answered
G

3

5

What is the User Agent string for Apple TVs running the new Apple tvOS operating system (which I believe is based on iOS)? Do they report themselves as being "iOS" devices?

Grannie answered 18/9, 2015 at 1:13 Comment(1)
What are you trying to do? An app that makes an HTTP request can set whatever value it wants as its User-Agent header.Prologue
S
3

The Apple TV does not support the WebKit framework, meaning you can't technically show webpages and therefore have a User Agent.

However, if you somehow had it running one the new TVOS, the User Agent would definitely be :

Mozilla/5.0 (Apple TV; CPU iPhone OS 9_0 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13T534YI

Soupy answered 18/9, 2015 at 13:35 Comment(0)
P
2

I didn't see any official documentation on this, but a number of people have reported the user agent for tvOS being something a long the lines of:

  • [AppName]/1 CFNetwork/758.1.6 Darwin/15.0.0

  • [AppName]/1 CFNetwork/758.1.2 Darwin/15.0.0

I have seen something similar. Here is mine:

  • [AppName]/1 CFNetwork/758.2.8 Darwin/15.2.0 Note: These User Agents can change.

You can check for yourself using a HTTP proxy and monitor, such as Charles. Also mentioned here on SO.

Sources:

Privileged answered 8/1, 2016 at 21:56 Comment(0)
N
2

tvOS does not currently (as of October, 2017) expose any web view components (such as UIWebView) in its SDK. However, you can still force tvOS to load UIWebView using reflection (see answer here), and then extract user agent string from it.

let webViewClass: AnyObject.Type = NSClassFromString("UIWebView")!
let webViewObject: NSObject.Type = webViewClass as! NSObject.Type
let webView: AnyObject = webViewObject.init()
let userAgent = webView.stringByEvaluatingJavaScript(from: "navigator.userAgent")
print(userAgent!)

Output:

Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Mobile/15J380
Narrow answered 18/10, 2017 at 19:13 Comment(1)
This solution works, but the output is describing it as iPhone instead of AppleTVStogner

© 2022 - 2024 — McMap. All rights reserved.