Cocoa webview UserAgent "webkit-legacy" issue
I've created simple sample application and fixed this issue. I've provided same user agent, as in Safari. After that, Shared Photos work as expected.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.webView.customUserAgent = @"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"; self.webView.mainFrameURL = @"https://messenger.com";}
After that, I compare user agents:
Original WebView user agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/600.8.9 (KHTML, like Gecko)
Safari user agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7
So, looks like I need to change only last part of User Agent. Like that:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.webView.applicationNameForUserAgent = @"Safari/601.2.7"; self.webView.mainFrameURL = @"https://messenger.com";}
With this code, Shared Photos also works. Unfortunately, it doesn't work with other applicationNameForUserAgent
values I've tried.
As promised, here's the answer.
I added this function in the ViewController
class.
func webView(sender: WebView!, didFinishLoadForFrame frame: WebFrame!) { webView.stringByEvaluatingJavaScriptFromString("document.body.className = 'safari webkit mac x1 Locale_en_US _z4_';")}
Pretty simple, but it's working perfectly fine.
I still have some problems with the app itself (e.g. Download image button doesn't trigger file explorer dialog), but basic functions like
- send/receive messages
- view shared pictures
work just fine.
I'm planning on working on this for
- download image
- notification
If you are interested in helping me out, please comment!
Thanks all for your help :)