Skip to content

Commit

Permalink
User agent fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhartford committed Apr 12, 2016
1 parent 4859dd8 commit 2e1af8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions SwiftR Mac Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ViewController: NSViewController {
// Or change myserver.com to localhost or IP below

// Default is false
SwiftR.useWKWebView = true
SwiftR.useWKWebView = false

// Default is .Auto
SwiftR.transport = .ServerSentEvents
Expand All @@ -34,8 +34,7 @@ class ViewController: NSViewController {
connection.queryString = ["foo": "bar"]
connection.headers = ["X-MyHeader1": "Value1", "X-MyHeader2": "Value2"]

// This only works with WKWebView on Mac OS X >= 10.11
// Otherwise, use NSUserDefaults.standardUserDefaults().registerDefaults(["UserAgent": "SwiftR Mac Demo App"])
// This only works with WKWebView on OS X >= 10.11, or with WebView on OS X >= 10.2.
connection.customUserAgent = "SwiftR Mac Demo App"

self?.simpleHub = connection.createHubProxy("simpleHub")
Expand Down
4 changes: 2 additions & 2 deletions SwiftR/SwiftR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ public class SignalR: NSObject, SwiftRWebDelegate {
if #available(OSX 10.11, *) {
wkWebView.customUserAgent = customUserAgent
} else {
print("Unable to set user agent for WKWebView on Mac OS X <= 10.10. Please register defaults via NSUserDefaults instead.")
print("Unable to set user agent for WKWebView on OS X <= 10.10.")
}
} else {
print("Unable to set user agent for WebView. Please register defaults via NSUserDefaults instead.")
webView.customUserAgent = customUserAgent
}
#endif
}
Expand Down

0 comments on commit 2e1af8b

Please sign in to comment.