Initial setup

Integrating the SDK

The Windows SDK is a WinRT component compatible with Windows 8.1, Windows Phone 8.1 and the UWP (Windows 10). It is distributed through NuGet.

You can install it from Visual Studio: Right click on your project and select "Manage NuGet Packages". Then, search for "BatchSDK" and install it.

You can also use the NuGet CLI:

PM> Install-Package BatchSDK

If you don't want to use NuGet with the online repository, you can dowload the nupkg and put it in your local repository, or unzip it and get BatchSDK.winmd from it.

Your first start

Finally, implement the Batch Start call in your App.cs App() constructor.

using BatchSDK;

namespace MyApp
{
    sealed partial class App : Application
    {
        public App()
        {
            ...
            
            // Enable dev logs
            Batch.Core.SetDebugWriter((s) => { System.Diagnostics.Debug.WriteLine(s); });
            Batch.Core.EnableDebugLogs = true;
            
            // Start Batch
            Batch.Core.Start("YOUR_API_KEY");
        }
    }
}

This snippet also shows you how to enable Batch logs and Debug logs. Feel free to tweak this to output the logs wherever you want or tweak the verbosity of the SDK.

Of course, your app will also need to declare the "Internet (client)" capability in your store manifest.

YOUR_API_KEY is your Batch Dev or Live API key. You'll find the API keys needed to set up the SDK in ⚙ Settings → General:

  • Dev API key: Use it for development or testing purposes. This API key won't trigger stats computation. Please take care not to ship an app on a Store with this API key.
  • Live API key: Should be used in a production environment only and in the final version of your app on the Store.

Testing your integration

Congratulations on finishing the bulk of the integration!

If you want to validate your implementation before proceeding with the Push setup, you can locate the log that Batch posts in the Visual Studio output panel:

[Batch] Batch (v1.5.0) started with a DEV API Key