News

Windows 10 Universal App Platform (UAP) Support

0 MIN READ • Mar 24, 2016

We are happy to announce that PubNub can now be used in Windows 10 Universal App Platform (UAP) applications. Building Windows apps with PubNub is quite easy. To follow these instructions you’ll need Windows 10 (obviously) and Visual Studio. The Visual Studio Community Edition 2015 will work fine.

Requirements

  1. Windows 10 OS
  2. Visual Studio Community Edition (free download)

Run the demo example

  1. Download the example code.
  2. Make sure you are targeting .NET Framework 4.5.2.
  3. This example uses PubnubPCL Nuget package
  4. Open PubnubWindowsStore.sln file and right-click on PubnubWindowsStore.prj project.
  5. Run the project

You can also create your own sample project with the following steps:

  1. Create new project:
    Create a New Project
  2. Install the latest PubnubPCL Nuget package.
    Open Manage NuGet Packages menu
    Select the PubNub NuGet package
  3. Now add your own code by instantiating Pubnub instance.
    Pubnub pubnub = new Pubnub("demo", "demo");
  4. Continue using the PubNub API as you would in any C# program.

Example Code

Here is a full publish and subscribe example:

example.cs
using PubNubMessaging.Core;

Pubnub pubnub = new Pubnub( "demo", "demo");

pubnub.Subscribe<string>(
    channel:"my_channel",
    DisplaySubscribeReturnMessage,
    DisplaySubscribeConnectStatusMessage,
    DisplayErrorMessage);

void DisplaySubscribeConnectStatusMessage(string connectMessage)
{
    Console.WriteLine("SUBSCRIBE CONNECT CALLBACK");
    pubnub.Publish<string>(
        channel:"my_channel",
        publishMsg:"Hello from the PubNub C# SDK",
        DisplayReturnMessage,
        DisplayErrorMessage);
}


void DisplaySubscribeReturnMessage(string result) {
    Console.WriteLine("SUBSCRIBE REGULAR CALLBACK:");
    Console.WriteLine(result);
    if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim()))
            {
                List<object> deserializedMessage = 
                    pubnub.JsonPluggableLibrary.DeserializeToListOfObject(result);
                if (deserializedMessage != null && deserializedMessage.Count > 0)
                {
                    object subscribedObject = (object)deserializedMessage[0];
                    if (subscribedObject != null)
                    {
                        //IF CUSTOM OBJECT IS EXCEPTED, YOU CAN 
                        //CAST THIS OBJECT TO YOUR CUSTOM CLASS TYPE
                        string resultActualMessage = 
                            pubnub.JsonPluggableLibrary.SerializeToJsonString(subscribedObject);
                   }
                }
            }
}

void DisplayErrorMessage(PubnubClientError pubnubError)
{
    Console.WriteLine(pubnubError.StatusCode);
}

void DisplayReturnMessage(string result)
{
    Console.WriteLine("PUBLISH STATUS CALLBACK");
    Console.WriteLine(result);
}

Using PubNub for Win10 UAP apps is as easy as any of our other SDKs, and it works everywhere UAP apps do. We can’t wait to see what you build.

For complete documentation please see the new PubNub C# PCL SDK with tutorials for features like Presence, History, Data Streams, and more.

Jan 19, 2024

Desktop Toast Notifications with C#, WPF & MVVM

This guide will walk you through building the front-end and back-end code for desktop notifications with the MVVM design pattern.
Darryn Campbell
Darryn Campbell
Dec 4, 2015

Real-time Monitoring: Server Load, Memory

Build Windows service application that monitors server processing load and memory consumption using PubNub's Data Stream Network.
Michael Carroll
Michael Carroll
Real-Time
Oct 25, 2026

PubNub DataSync vs. real-time databases: Where your app's live state belongs

When to keep live app state in PubNub DataSync, when you still need a real-time database, and how a marathon app splits its data between them.
Dawid Urbas
Dawid Urbas