mutahir-mehmood1102 avatar image
mutahir-mehmood1102 asked vyshakhbabji commented

Having Issue When Using C# SDK and using Presence API

Hi everyone,

I am having an issue with C# sdk and Pubnub Presence api. I can subscribe to Presence but no data is being received when ring central phone changes its state. I have created an equivalent javascript application which subscribes with same sub key and channel and it gets the notifications whenever ring central phone changes its state (whenever agent goes in a call or a call ends or agent changes its state manually) but this is not happening for C# application. Right now I am using sample application from github provided by Pubnub but it doesn't work

Note: all the communication is encrypted and I have specified the cipher key as well


1 |1500

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

benjamin-dean avatar image
benjamin-dean answered John Wang commented
We are aware of these blocking issues which have been reported in the Github repository for the RingCentral C# SDK, and we are working on prioritizing this work to get our developers unblocked.

In the meantime, the RingCentral C# SDK is open source, and we welcome contributions from our community. Please see the Github Issue tracker for reported issues and follow the contribution documentation to become an active contributor this open source project.

This issue has more activity on this thread, please consider this post deprecated and use the original post for any content or new relating issues:
1 comment
1 |1500

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

There are some open issues on the C# SDK but those only come into effect in a long-running subscription. The code provided below will subscribe to and receive decrypted events using the C# SDK.
0 Likes 0 ·
vyshakhbabji avatar image
vyshakhbabji answered vyshakhbabji commented
Please have a look at this code. I have subscription and presence working in C#. This should help :
1 |1500

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Hi Thanks for your help but, I am little confused when I was looking at your code. dont we have to use pubnub.Presence<string>()  method when we are looking to get notified on Presence? but instead you just used pubnub.Subscribe<string>(). Can you please clarify this? I am a newbie to pubnub
0 Likes 0 ·
You are subscribing to presence event through subscription API. Please read the document here for subscription API .

The subscription api will help you subscribe to presence api so that you dont have to poll for presence api. 
0 Likes 0 ·
John Wang avatar image
John Wang answered
Using the C# SDK, the following example code should get you started. I just verified it working and receiving decrypted events. Since the C# SDK will automatically decrypt the PubNub payload, you should not need to specify any cipher keys yourself.

The following app is a console app that will listen to presence events and print out state changes. I've also added this example code here.  
using System;  using RingCentral.SDK; using RingCentral.Subscription;  namespace console.subscribe {     class MainClass     {         static void ActionOnNotification(object message) {             var receivedMessage = message.ToString();             Console.WriteLine(receivedMessage);         }          static void ActionOnConnect(object message){             var receivedMessage = message.ToString();             Console.WriteLine(receivedMessage);         }          static void ActionOnError(object error) {             var receivedMessage = error.ToString();             Console.WriteLine(receivedMessage);         }          public static void Main (string[] args)         {             var url = "";             var sdk = new RingCentral.SDK.SDK("myAppKey", "myAppSecret", url, "appName", "appVersion");             sdk.GetPlatform().Authorize("myUsername", "myExtension", "myPassword", true);              var sub = new SubscriptionServiceImplementation(){ _platform = sdk.GetPlatform()};             sub.AddEvent("/restapi/v1.0/account/~/extension/~/presence");              sub.Subscribe(ActionOnNotification, ActionOnConnect, ActionOnError);              Console.ReadLine();             Console.WriteLine("Hello World!");         }     } }

1 |1500

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys