Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 22.214.171.124 release ready!
Updated 31 March 2022
Socket.io is a library that enables event-based communication between client to server
1. You have to write the below line in your point and in your terminal run the command pod install
This will help you to integrate the real-time chat
2. Import the library for this library where you want to use it
3. Create a class to perform the event for the chat system like below.
4. Add the socket url or port url in this Class using below code.
5. Initiate the class and start or connect the server.
in the above line of code socket.on it will not connect to the server it is an event when the server will connect the data will print
6. please create function, and within the function, you connect the server from the app
if you are using function, you can use this code from anywhere else
If you want to connect the server on the app startup you need to connect the server from the appdelegate class
Please check the below code to connect the server from the appDelagate
7. If you want to close the connection or reconnect the server please follow the below link
8. Please add the event to recieve the message from other end
In the above code there is a notificationcenter.default.post this will help you to fatch the received data and reload the message in the controller
9. This is the last but not the least
By using below code you can send the message to the other user
I hope this blog will help you to implement realtime Chat, if you have any queries, comments, questions, or recommendations, feel free to post them in the comment section below!
if you want to read more about custom socket.io click here.
For other technical blogs, please click here.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.