With the Play Games PC SDK you can access Google Play services to build and
monetize your game on PCs. Sell digital content using Play Billing, seamlessly
sign-in using Play Games, and verify your users have a valid entitlement to your
application with Play Integrity.

Ready to get started?

## Prerequisites

- Create an app entry inside of the Play Console and claim a Play package name.

- Download and install
  [Google Play Games for PC](https://play.google.com/googleplaygames) and sign in with
  your Google Account.

## **Step 1**: Add the SDK to your project

| **Note:** The SDK officially supports C++. If you are using a programming language other than C++ please reach out to your Google Partner letting them know what game engine \& programing language your application uses to see if we can better support you.

- Download the [Play Games PC C++ SDK](https://developer.android.com/games/playgames/native-pc/downloads/cpp).

- Copy the API headers folder `includes/` into your application's codebase.

- Copy the redistributable files from `imports/` into your application's
  project.

  - Link your project against `play_pc_sdk.lib` allowing access to the contents of the `play_pc_sdk.dll`.

## **Step 2**: Add a manifest file

Before you can use the SDK from within your game you will need to
associate your game executable with the Play package name that you claimed
inside of the Play Console. This done by adding a `manifest.xml` file in the
same directory as your game's executable.

Example `manifest.xml` contents:  

    <?xml version="1.0" encoding="utf-8"?>
    <Manifest version="1">
        <Application>
            <PackageName><var translate="no">com.example.package</var></PackageName>
        </Application>
    </Manifest>

Example `manifest.xml` placement:  

    C:\Program Files
    └───Example Game
        ├───Game.exe
        └───manifest.xml

## **Step 3**: Digitally sign your game

| **Tip:** Developers can skip this step during local development by enabling [developer mode](https://developer.android.com/games/playgames/native-pc/setup/developer_mode).

Before your game can use the SDK, the game's executable must be digitally signed
using an
[Authenticode Digital Signature](https://learn.microsoft.com/en-us/windows-hardware/drivers/install/authenticode).
For instructions on how to sign an executable see the
[documentation on the SignTool](https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool) .

When you have completed the process for digitally signing your game, send the
certificate information to your Google representative for configuration.
| **Warning:** Safeguard your certificate properly. You must sign all updates to your game using the same certificate.

## **Step 4**: Initialize the SDK

Initialize the SDK during the startup sequence of your game. This should be done
automatically without requiring any user interaction and it is recommended to
verify a successful initialization before rendering your game window.
This provides the best user experience by surfacing and resolving errors as soon
as possible and avoids your game window briefly appearing in cases where your
game process needs to exit.

Start using the SDK by calling
[`GooglePlayInitialize`](https://developer.android.com/games/playgames/native-pc/reference/namespace/google/play/initialization) to initialize the API. This
will setup global state, connect with the SDK runtime, and verify the
application was started correctly. This **MUST** be called and have the
continuation callback complete with `InitializeResult::ok()` equal to `true`
before any other API may be used.  

    // Initialize the SDK as part of the startup sequence of your application.
    auto promise = std::make_shared<std::promise<InitializeResult>>();
    GooglePlayInitialize(
      [promise](InitializeResult result) {
        promise->set_value(std::move(result));
      });

    auto initialize_result = promise->get_future().get();
    if (initialize_result.ok()) {
      // The SDK succeeded with initialization. Continue with the startup sequence
      // of the game.
      // ...
    } else if (initialize_result.code() == InitializationError::kActionRequiredShutdownClientProcess) {
      // The SDK failed to initialize and has requested that your game process exit
      // as soon as possible.
      exit(1);
    } else {
      // The SDK failed to initialize for an alternative reason. It is still
      // generally recommended that you exit the game process as soon as possible,
      // because it won't be possible to access any APIs in the SDK. Critical
      // operations such as verifying the user owns a valid license to your game
      // won't be possible.
      // ...
    }

If the initialization fails with the code `kActionRequiredShutdownClientProcess`
**exit the game process as soon possible**. The SDK's runtime will attempt
to assist the user with no additional action required by your game. For example
if the user does not own a valid license to the game, Google Play Games will
prompt the user to purchase a copy. For other errors it is still recommended to
exit the game process as soon as possible as it won't to use the SDK to
perform critical operations such as verifying the user owns a valid license
to your game.

A non-successful response may indicate one of the following conditions:

- The SDK runtime is not installed, is not running on the device or is
  an older version not compatible with the SDK integrated into your game.

- The SDK runtime was unable to verify the application identity of the
  game. This could be due to an invalid `manifest.xml` or using the SDK
  without enabling [developer mode](https://developer.android.com/games/playgames/native-pc/setup/developer_mode)
  when developing. Without this your game's executable is required to be
  digitally signed with the digital certificate registered to your Play package
  name.

- The game executable was not launched through the Google Play games client.

- The active user in Google Play Games does not own a license for the
  application.

## **Step 5**: (Optional) Supporting multiple game-processes

If your game uses multiple processes -- for example, if Play Games PC loads
your launcher, then your launcher starts the actual game -- and plans to use
the Play Games PC SDK from a process that is not directly launched by Google
Play Games for PC -- if your actual game, started from your launcher, needs to
use the Play Games PC SDK -- complete these additional integration steps:

1. The process directly launched by Google Play Games for PC must
   verify a successful [initialization of the Play Games PC SDK](https://developer.android.com/games/playgames/native-pc/setup#step-4).

   This provides the best user experience by surfacing errors as soon as
   possible. Note that child-process using the SDK must also perform
   initialization in addition to the directly launched process.
2. To use the Play Games PC SDK in a child-process forward the command line
   parameters to the spawned child-process.

   Example command line parameter forwarding:  

       Processes hierarchy tree:

       GooglePlayGames.exe
       └───YourGameLauncher.exe --gpg_args=abc --your_args=123
           └───YourGame.exe --gpg_args=abc --your_args=123

   In this example we see a process hierarchy where Google Play Games for PC
   (`GooglePlayGames.exe`) launches the game (`YourGameLauncher.exe`) with some
   example parameters (`--gpg_args=abc --your_args=123`). The game then spawns a
   child-process (`YourGame.exe`) which uses the Play Games PC SDK. To allow this
   the game process launched by Google Play Games for PC forwards the command
   line parameters it was given to the child-process.
   | **Warning:** You must pass all command-line arguments received from `GooglePlayGames.exe` to all your child processes that are using Play Games PC SDK, such as `YourGame.exe`. Otherwise, all SDK functions fail.
3. Exit all processes when the game stops running.

   When a user closes your game or the game exits due to a SDK initialization
   failure, such as `kActionRequiredShutdownClientProcess`, close all processes
   your game has spawned. This makes certain that the next time your game is
   launched by the Google Play Games for PC client, new changes such as switching
   to a different active account will take effect.

## Next steps

Use the SDK while developing in your IDE:

- Enable [developer mode](https://developer.android.com/games/playgames/native-pc/setup/developer_mode)

Add Google Play PC features to your app:

- Sell digital goods with [Play Billing](https://developer.android.com/games/playgames/native-pc/billing)
- Measure your marketing with [Play Install Referrer](https://developer.android.com/games/playgames/native-pc/install_referrer)
- Protect your game with [Play Integrity for PC](https://developer.android.com/games/playgames/native-pc/trust)