简体   繁体   中英

Does the WKWebView support websocket?

I have very short question. I'm starting to develop an app, which is targeted to Android, but why not try to use it on iOS? Application has WebView only and it will use WebSocket for communication.

My question is, does the UIWebView support WebSocket or is it necessary to use external libraries? I don't have an Apple device to check and didn't find any information in the internet.

Thanks for any hint.

EDIT:I've read that UIWebView is deprecated. What about WKWebView?

I have found that WKWebView does support Web Sockets. What really surprised me is it also supports keeping the websockets open in the background (assuming you have the appropriate requirements set up in your app). You can then pass messages to the native side as required using the messageHandlers.postMessage mechanism.

Alternatively if you wanted to take a more native approach you could use SocketRocket which is a library developed by Facebook

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM