Sending news and update notifications using Messaging API
The new Messaging API allows you to easily send notifications to some or all of your end users. For example, it can help you to notify customers running an older version of your application to upgrade as well as keep them updated about the latest news.
Getting Started
It’s quite simple to get started with the Messaging API. The dashboard is available here, which is where you can send the messages. In order receive them in your own app, you can use the GetMessages method. One thing to keep in mind are the two optional parameter, time and channel. These allow you to tell Cryptolens which messages you want to receive. Time is used as a reference when the last message was seen and channel is a way to group those messages. If these are not specified, all of the messages will be returned.
For example, let’s say you want to implement updates notifications. In that case, we can use the code below to ensure that only older versions of the software receive the message. The version itself is specified as a unix timestamp in the currentVersion parameter, which should be the time when you published the release.
var currentVersion = 1538610060; var result = (GetMessagesResult)Message.GetMessages("token with GetMessages permission", new GetMessagesModel { Channel = "stable", Time = currentVersion } ); if(result == null || result.Result == ResultType.Error) { // we could not check for updates Console.WriteLine("Sorry, we could not check for updates."); } else if (result.Messages.Count > 0) { // there are some new messages, we pick the newest one // (they are sorted in descending order) Console.WriteLine(result.Messages[0].Content); } else { // No messages, so they have the latest version. Console.WriteLine("You have the latest version."); } Console.Read();
You can see the entire tutorial about updates notifications for more details. There is also about notifications.