Hi Mark,
I’m having trouble trying to retrieve messages from a channel, the latest documentation on the web site doesn’t seem to show examples of how to implement this in C#. Please help in this regard.
Kind Regards,
Labi
Hi Mark,
I’m having trouble trying to retrieve messages from a channel, the latest documentation on the web site doesn’t seem to show examples of how to implement this in C#. Please help in this regard.
Kind Regards,
Labi
@Onkemetse_Labi please check out doc https://backendless.com/docs/android/pubsub_overview.html it shows how to use messaging for android. Approach for .NET is pretty much the same.
Problem with the documentation is that in Java/Android you can create a Channel Object and instantiate it. In C# .Net you can only subscribe to a channel and not instantiate that Because only IChannel is available. Please provide an example in C# for me of how to subscribe to the channel and add a Listener…
@Onkemetse_Labi
IChannel has an implementation you should not worry about it. Here it is an example that I have checked right now:
using System;
using BackendlessAPI;
namespace TestMessaging
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Backendless.InitApp("your-app-id", "your-api-key");
Backendless.Messaging.Subscribe().AddMessageListener<String>((message) => Console.WriteLine(message));
Console.ReadLine();
}
}
}
I have published through backendless console two messages:
test messageing
my new message
and output is:
Hello World!
BACKENDLESS LOG:try to subscribe RTSubscription{id='6d97540a-eb0a-46d5-8087-ee2d61233c05', callback=BackendlessAPI.RT.RTCallback`1[System.Object], subscriptionName=PUB_SUB_CONNECT, options=System.Collections.Generic.Dictionary`2[System.String,System.Object]}
BACKENDLESS LOG:Connected event
BACKENDLESS LOG:subOn called
BACKENDLESS LOG:Got sub res
BACKENDLESS LOG:Got result for subscription 6d97540a-eb0a-46d5-8087-ee2d61233c05
BACKENDLESS LOG:try to subscribe RTSubscription{id='f4bcf072-3b1d-4354-b6ac-7dd10f1d0cf6', callback=BackendlessAPI.RT.RTCallback`1[System.String], subscriptionName=PUB_SUB_MESSAGES, options=System.Collections.Generic.Dictionary`2[System.String,System.Object]}
BACKENDLESS LOG:subOn called
BACKENDLESS LOG:Got sub res
BACKENDLESS LOG:Got result for subscription f4bcf072-3b1d-4354-b6ac-7dd10f1d0cf6
test messageing
BACKENDLESS LOG:Got sub res
BACKENDLESS LOG:Got result for subscription f4bcf072-3b1d-4354-b6ac-7dd10f1d0cf6
my new message
Thanks a million … I assume I can pass the message into a string object or a list?