Tells the delegate that the WebSocket task successfully negotiated the handshake with the endpoint, indicating the negotiated protocol.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- watchOS 6.0+
Framework
- Foundation
Declaration
- (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSession Web Socket Task *)webSocketTask didOpenWithProtocol:(NSString *)protocol;
Parameters
session
The session of the WebSocket task that opened.
webSocketTask
The WebSocket task that opened.
protocol
The protocol picked during the handshake phase. This parameter is
nil
if the server did not pick a protocol, or if the client did not advertise protocols when creating the task.
Discussion
If the handshake fails, the task doesn’t call this delegate method.