Ask tech team
From QuickBlox Developers (API docs, code samples, SDK)
(Redirected from WindowsPhone)
Jump to: navigation, search


Download UWP SDK

You can download QuickBlox UWP (Universal Windows Platform) SDK from NuGet. To install Quickblox Sdk, run the following command in the Package Manager Console:

Install-Package Quickblox.Sdk

or just search for "Quickblox Sdk" in NuGet package manager.

You can use this SDK in your Windows Phone (version 8.0 and newer) and in Windows 8 (and newer) applications.

Code samples

Learn how to enable Push Notifications, create a Chat room, store and retrieve files from the cloud with our sample chat application Q-Municate. You can find Q-Municate source code on GitHub. Q-Municate application is available in Windows Store.

WpChat.jpg WpChatList.jpg WpProfile.jpg

Getting started

Windows SDK is really simple to use. In just a few minutes you can power up your mobile app with huge amount of awesome communication features & data services.

var quickbloxClient = new QuickbloxClient(applicationId, authKey, authSecret);

By default QuickbloxClient is configured to work with the shared server ( If you have a dedicated server you need to provide your API endpoint and Chat Endpoint to the QuickbloxClient constructor.

Authentication and Authorization

To be able to use QuickBlox API you have to create a session.

There are 2 types of session:

  • Application session. It provides only READ access to data.
  • User session. It provides CRUD(Create, Read, Update, Delete) access to data.

User sign up scenario

You can create an Application session with just the following code:

var sessionResponse = await quickbloxClient.AuthenticationClient.CreateSessionBaseAsync();

If session is successfully created sessionResponse.StatusCode is going to be equal HttpStatusCode.Created and quickbloxClient.Token will contain the token for current session.

Then you can sign up a new user:

var userSignUpRequest = new UserSignUpRequest
                User = new UserRequest()
                    Email = email,
                    FullName = fullName,
                    Password = password
var response = await QuickbloxClient.UsersClient.SignUpUserAsync(userSignUpRequest);

After this you can upgrade your session to User session:

var loginResponse = await QuickbloxClient.AuthenticationClient.ByEmailAsync(email, password);

User sign in scenario

To login an existing user use CreateSessionWithEmailAsync or CreateSessionWithLoginAsync methods.

var sessionResponse = await QuickbloxClient.AuthenticationClient.CreateSessionWithEmailAsync(email, password);

If session is successfully created sessionResponse.StatusCode is going to be equal HttpStatusCode.Created and quickbloxClient.Token will contain the token for current session.

Connecting to server

ChatXmpp module in Windows SDK provides instant messaging functionality. You need to connect to a server before using it:

await QuickbloxClient.ChatXmppClient.Connect(userId, password);

Private chat

Initializing private chat manager. You need to provide an ID of a user you want to chat with as a parameter. ChatManagerOnOnMessageReceived callback in going to be fired when you receive a message:

var privateChatManager = QuickbloxClient.ChatXmppClient.GetPrivateChatManager(otherUserId, dialogId);
privateChatManager.MessageReceived += ChatManagerOnOnMessageReceived;

Sending a message:


Group chat

To initialize a group chat manager you need to provide XMPP room JID and corresponding dialog ID.

groupChatManager = QuickbloxClient.ChatXmppClient.GetGroupChatManager(xmppRoomJid, dialogId);
groupChatManager.MessageReceived += ChatManagerOnOnMessageReceived;

Before you can send or receive any group messages you need to join the group:


Sending a message:


Push notifications

You can subscribe a device for push notifications in one request. At first you need to create a CreateSubscriptionsRequest object:

var pushChannel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var createSubscriptionRequest = new CreateSubscriptionsRequest()
             DeviceRequest = new DeviceRequest() { Platform = Platform.windows_phone, Udid = Helpers.GetHardwareId() },
             PushToken = new PushToken()
                             Environment = Environment.production,
                             ClientIdentificationSequence = pushChannel.Uri
             Name = NotificationChannelType.mpns

Then you can create a subscription:

var createPushTokenResponse = await quickbloxClient.NotificationClient.CreateSubscriptionsAsync(createSubscriptionRequest);
if (createPushTokenResponse.StatusCode == HttpStatusCode.Created)
      // subscription was created

Content storage

Use ContentClient to manage your content. The general workflow for file upload is:

1. Create a file info with CreateFileInfoAsync method

2. Upload your file with FileUploadAsync method

3. Declare your file uploaded with FileUploadCompleteAsync method

You can use ContentClientHelper instead to simplify your workflow with images. Uploading a public image:

var uploadResult = await contentHelper.UploadImage(imageBytes, true);

XML documentation

Full reference on classes and interfaces used in QuickBlox Windows SDK (XML Documentation):