WebSockets In Swift — IOS Development

Umair Ishrat Khan
4 min readJan 5, 2022
WebSockets In Swift
Realtime programming in swift

What is WebSocket ? Why do we use it ? And why did I used an image of clock?

Well WebSocket is a communication protocol that follows stateful protocol and helps us to build Real Time Application (RTA) & thats why I used a clock image. A simple example for it is chat application. If you want to learn more about WebSocket please refer to my article where I’ve made a comparison between REST & WebSocket.

For this tutorial I am going to use a demo api you can get it from here. Enough of the theory lets move to practical implementation.

Practical Implementation For WebSocket In Swift :

In the code above we have created a UIButton and added it to the View & added the button target this button will help us to disconnect our WebSocket session. So on touchUpInside action our button will call the function closeSession() on line 34.

--

--

Umair Ishrat Khan
Umair Ishrat Khan

Written by Umair Ishrat Khan

An energetic and motivated individual IOS developer/ Data Science Practitioner. Apart from computer science Martial arts interests me the most.

Responses (2)