独自のアカウント システムを引き続き使用しながら、ユーザーをゲームにシームレスにログインさせます。Play Games Services Recall API を使用すると、ゲーム内アカウントを Google Play Games Services アカウントにリンクできます。ユーザーが複数のデバイスでゲームをプレイする場合(またはゲームを再インストールした後に同じデバイスでプレイする場合)、リンクされたゲーム内アカウントをクエリして、ログインフローを効率化できます。
Android Recall API と統合している場合は、これらの Recall API に見覚えがあるはずです。Play ゲームサービスのリコールとのサーバーサイドの統合は、Android と PC で同じであるため、PC タイトルで再利用できます。
前提条件
SDK の設定を完了します。
Play Games Services Recall API の概要を確認します。
Google Play Console で Google Play ゲームサービスの設定を完了します。
ステップ 1: マニフェストに Google Play ゲームサービス プロジェクト ID を追加する
Google Play Console で Play ゲームサービスの設定を完了すると、ゲームに Play ゲームサービスのプロジェクト ID が関連付けられます。このプロジェクト ID(Google Play Console の Google Play Games サービスの設定ページで確認できます)を使用して、ゲームの manifest.xml を更新します。
manifest.xml コンテンツの例:
<?xml version="1.0" encoding="utf-8"?>
<Manifest version="1">
<Application>
<PackageName>com.example.package</PackageName>
<PlayGamesServices>
<ProjectId>123456789</ProjectId>
</PlayGamesServices>
</Application>
</Manifest>
ステップ 2: ログイン時に Recall へのアクセスをリクエストする
ゲームがログインフロー(ゲーム内アカウントの追加など)を処理している場合は、GamesRecallClient::RequestRecallAccess() を使用して Recall へのアクセスをリクエストします。
この呼び出しは、ゲーム内アカウントと Play Games サービス ユーザーのリンクとリンク解除のために、バックエンドが Google にサーバーサイド呼び出しを行う際に使用するセッション ID を返します。
auto promise = std::make_shared<std::promise<RecallAccessResult>>();
games_recall_client.RequestRecallAccess(params, [promise](RecallAccessResult result) {
promise->set_value(std::move(result));
});
auto recall_access_result = promise->get_future().get();
if (recall_access_result.ok()) {
auto recall_session_id = recall_access_result.value().recall_session_id;
// Pass the recall session ID to your backend game server so it can query
// for an existing linked in-game account.
// - If you discover an existing linked in-game account, continue to sign-in
// the in-game account. This provides a seamless cross-device sign-in
// experience.
// - If there is not an existing linked in-game account, when the user
// completes the sign-in using your in-game account system record the
// account linking with Play Games Services Recall. This helps to provide
// a seamless cross-device sign-in experience when the user returns on a
// different device or after re-installing your game on the same device.
} else {
// Handle the error
}
ステップ 3: Recall セッション ID を処理する
ゲームがリコール セッション ID を取得し、バックエンド ゲームサーバーに渡したら、Play Games サーバーサイド REST API を使用して次の操作を行います。
recall.retrieveTokensを使用して既存のリンク済みゲーム内アカウントをクエリするrecall.linkPersonaを使用して、リンクされたゲーム内アカウントを追加または更新するrecall.unlinkPersonaを使用して、リンクされたゲーム内アカウントを削除する
サーバーサイドの統合について詳しくは、ゲームサーバー内で Recall API を使用する方法に関するドキュメントをご覧ください。