Developers » Windows Phone SDK
Windows Phone SDK
VK SDK makes using VK API in Windows Phone applications much easier. Users can pass the authorization without entering a login and a password. You may start using API methods right away.
Project page and source code at GitHub:
http://github.com/VKCOM/vk-windowsphone-sdk

Windows Phone versions 8.0 and higher are supported.
Preparing to use VK SDK
Before using VK SDK you need to create a Standalone app at the app creation page. Save your app ID (it will be the API_ID parameter in the documentation).
Fill in the Windows App ID field to enable authorization through VK official app.
For Silverlight apps it is ProductId from the WMAppManifest.xml file. For XAML apps it is Identity.Name from Package.appxmanifest. In both cases it is a guid type value (for example 5130dfdb-3c66-490b-8f50-d62b757efde5).

Connecting the SDK in a Windows Phone App
Add a link to the VK.WindowsPhone.SDK project.
Source code at GitHub
Working with the SDK
SDK Initialization
Before using VK SDK you need to initialize it:
VKSDK.Initialize("%your_app_id_here%");
VKSDK.WakeUpSession();
User Authorization
Authorizing a User Through WebView
Processed by following method:
VKSDK.Authorize

User will be redirected to the authorization page. If it is passed successfully following event will be called:
VKSDK.AccessTokenReceived

 Otherwise:
VKSDK.AccessDenied


Auhtorizing a User Through VK Official App
The VK app starting from version 4.1 supports third-party apps authorization.

For authorization callback address protocol:
VKSDK.Authorize(_scope, false, false, LoginType.VKApp);

Specify the callback address protocol in your app (it allows the VK app to return control).
For Silverlight apps specify the following protocol in the WMAppManifest.xml file:
<Extensions>
   <Protocol Name="vkc%your_windows_app_id%" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>

For XAML apps specify the protocol in the Package.appxmanifest file:
<Extensions>
   <Extension Category="windows.protocol">
      <Protocol Name="vkc%your_windows_app_id%" m2:DesiredView="useLess"/>
   </Extension>
</Extensions>

Add the VKConfig.xml (build action = content) file to the project's root directory:
<?xml version="1.0" encoding="utf-8" ?>
<Extensions>
   <Protocol Name="vkc%your_windows_app_id%" />
</Extensions>
Calling Methods
You may use the built-in SDK methods or get an access token and use your own library.

To call API methods use the VKRequest class.
For example to get current users friends:
VKRequest.Dispatch<VKList<VKUser>>(new VKRequestParameters("friends.get", "fields", "photo_200"), (res) =>
{
 if (res.ResultCode == VKResultCode.Succeeded)
 {
      var data = res.Data;
      /* your code handling successful execution here */
 }
else
{
    var error = res.Error; /* can be null */
    var failureCode = res.ResultCode;
    /* your code handling a failure here */
}
} );

While deserializing server replies the structure of the type transmitted in Dispatch<T> (in the previous example it is VKList<VKUser>) is supposed to match the JSON string returned by the server.
You may transmit your own deserialization function from JSON if needed. For this use the extra parameter of the Dispatch method: Func<string, T> customDeseriailzationFunc = null.
All the SDK model classes (such as VKUser) are declared as partial.

To upload photos to the server use the VKUploadRequest class:
VKUploadRequest.CreatePhotoWallUploadRequest().Dispatch(
                yourImageStream,
                (progress) =>
                {
                    /* your progress handler */
                },
                (res) =>
                {
                    /* your result handler */
                });
In-app purchase tracking
In case of placing your app at Mobile catalog you should call VKAppPlatform.ReportInAppPurchase in each in-app purchase event:
var results = await CurrentApp.RequestProductPurchaseAsync("product1");

if (results.Status == ProductPurchaseStatus.Succeeded)
{
   VKAppPlatform.Instance.ReportInAppPurchase(
      new VKAppPlatform.InAppPurchaseData(
         results.ReceiptXml,
         product.FormattedPrice));
}

Creating Wall Posts
SDK provides the UI to create wall posts. The VKSDK.Publish(inputData) method is used for it. The user will be redirected to the post creation page. The inputData object contains Text, Image and ExternalLink properties, values of which initialize this page.
Processing Validation Error and Captcha
SDK processes the Validation Error automatically. To correctly process captcha you need to set a handler for VKSDK.CaptchaRequest. It is recommended to use the VKCaptchaRequestControl in a handler. This control is a part of SDK:

        private void CaptchaRequest(VKCaptchaUserRequest captchaUserRequest, Action<VKCaptchaUserResponse> action)
{
               /* put an instance of VKCaptchaRequestControl on your page and instantiate it */
                captchaRequestControl.ShowCaptchaRequest(captchaUserRequest, action);

}