IOS implementing SignalR using Objective-C

For the past few weeks i been doing some research on SignalR in Objective C and i found very few resources available on the internet for implementing signlR in Objective-C. Therefore i thought of writing this tutorial, hoping it will help some developers one day.

In this tutorial i will explain you, how to  get connected to SingalR hub using IOS and Objective-C. This tutorial is not for beginners.

All Information about SignalR Objective-C library can be found in this Link.

Lets setup the environment first. flow the steps below

  1. First of all create a new IOS Objective C project.
  2. Close the project and navigate to the project directory Using Terminal.
  3. Create a new podfile and save the following code. (make sure to change your project name instead of signalRObjective2)
This will install required libraries such as AFNetworkingSocketRocket and as well as SignalR-ObjC

4. Now run the below command  in your terminal

pod install

. This will install all the required libraries and create a file with extension .xcworkspace in side your project folder.

5. Open the file yourproject.xcworkspace file

Now we got over environment setup , lets do the real coding to get connected to SignalR HUB.

In order to do a signal R communication, You need to understand three main factors in Signal R, They are explained below

  1. get connected – You must get connected to signalR Hub and keep the connection with out closing it.
  2. Subscribe to hub method – You must create a subscription to your hub method at the time of connection.
  3. Invoke hun method – You must invoke a hub method, when ever you want to send some message to the Hub and also receive the response through the subscribed method as explained before.

Now lets see how to implement it.


As you can see from the above code, you will have to tell the signalR hub URl and also the hub proxy name to the signalR-ObjectiveC library.

Then you need to subscribe to the Hub method as shown in the above code. serviceStatus is the hub method and it will return the response to testMethod which is in the client side.

Invoking a method in signalR hub is very simple as shown in the above code. And if you code dont have any parameters. Your invoke will be like this as shown below

That it. Over all Code will be as shown below

That is. If you have any problems are suggestions please be free to comment below, I will be happy to respond them.Thank you. Happy Coding 🙂