简体   繁体   中英

Using Azure Notification Hub to push to C# WinForms app

I am currently pushing notifications from my Desktop C# WinForms app to iOS devices. Is it possible to do the same other way around? eg Sending notifications from iOS device to WinForms app.

If not possible, what would be the best practices for letting know the WinForms application that iOS app perform certain task(s).

Thank you!

Azure Notification Hub is often used for mobile devices. For Winforms app, I suggest you Azure Service Bus topics service.

On your IOS side, you could send the message to the topic.

var connectionString = "<your connection string>";
var topicName = "<your topic name>";

var client = TopicClient.CreateFromConnectionString(connectionString, topicName);
var message = new BrokeredMessage("This is a test message!");

client.Send(message);

On your Winform side, you could subscribe the topic and receive messages from the topic. After received the message, you could do anything you want in your Winform application.

var connectionString = "<your connection string>";
var topicName = "<your topic name>";

var client = SubscriptionClient.CreateFromConnectionString(connectionString, topicName, "<your subscription name>");
client.OnMessage(message =>
{
  Console.WriteLine(String.Format("Message body: {0}", message.GetBody<String>()));
  Console.WriteLine(String.Format("Message id: {0}", message.MessageId));
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM