這個呼叫會傳回工作階段 ID,後端會使用這個 ID 向 Google 發出伺服器端呼叫,藉此連結及取消連結遊戲內帳戶與 Play 遊戲服務使用者。
autopromise=std::make_shared<std::promise<RecallAccessResult>>();games_recall_client.RequestRecallAccess(params,[promise](RecallAccessResultresult){promise->set_value(std::move(result));});autorecall_access_result=promise->get_future().get();if(recall_access_result.ok()){autorecall_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}
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[],[],null,["# Integrate the Play Games Services Recall into your app\n\nSeamlessly sign users into your game while continuing to use your own account\nsystem. With Play Games Services Recall APIs you can link in-game accounts with\na Google Play Games Services account, then when a user plays your game across\ndifferent devices (or the same device after re-installing your game) you query\nthe linked in-game account and streamline the sign-in flow.\n\nIf you have integrated with the [Android Recall APIs](/games/pgs/recall/recall-setup), these\nRecall APIs should look familiar. Any server-side integrations with Play Games\nServices Recall can be reused by PC titles as they are the same across both\nAndroid \\& PC.\n\nPrerequisites\n-------------\n\n- Complete the [SDK setup](/games/playgames/native-pc/setup).\n\n- Read the overview of [Play Games Services Recall API](/games/pgs/recall).\n\n- Complete [Google Play Games Services setup](/games/pgs/console/setup) in the Play Console.\n\n**Step 1**: Add your Play Games Services project ID in the manifest\n-------------------------------------------------------------------\n\nAfter completing the Play Games Services setup in the Play Console, your game\nnow has an associated Play Games Services' project ID. Using this project ID,\nwhich can be found inside Play Games Service's\n[Configuration page](https://play.google.com/console/u/0/developers/app/games/configuration-summary) in the Play Console, update\nyour game's `manifest.xml`.\n\nExample `manifest.xml` contents: \n\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003cManifest version=\"1\"\u003e\n \u003cApplication\u003e\n \u003cPackageName\u003e\u003cvar translate=\"no\"\u003ecom.example.package\u003c/var\u003e\u003c/PackageName\u003e\n \\\u003cPlayGamesServices\\\u003e\n \\\u003cProjectId\\\u003e\u003cvar translate=\"no\"\u003e123456789\u003c/var\u003e\\\u003c/ProjectId\\\u003e\n \\\u003c/PlayGamesServices\\\u003e\n \u003c/Application\u003e\n \u003c/Manifest\u003e\n\n**Step 2**: Request Recall access when signing-in\n-------------------------------------------------\n\n| **Tip:** We recommend using the Recall API to query for linked in-game accounts each time your game is launched. For new installs a linked in-game account can be used to seamlessly sign-in a user and restore their progress. For existing installs, when the linked in-game account changes it signals that the user switched accounts on a different device and you can save them time by switching to that account.\n\nWhen your game is handling a sign-in flow, for example adding an in-game\naccount, request Recall access using\n[`GamesRecallClient::RequestRecallAccess()`](/games/playgames/native-pc/reference/class/google/play/games/recall/games-recall-client#requestrecallaccess).\n\nThis call returns a session ID which is used by your backend to make server-side\ncalls to Google for linking \\& unlinking your in-game accounts with a Play Games\nServices user. \n\n auto promise = std::make_shared\u003cstd::promise\u003cRecallAccessResult\u003e\u003e();\n games_recall_client.RequestRecallAccess(params, [promise](RecallAccessResult result) {\n promise-\u003eset_value(std::move(result));\n });\n\n auto recall_access_result = promise-\u003eget_future().get();\n if (recall_access_result.ok()) {\n auto recall_session_id = recall_access_result.value().recall_session_id;\n // Pass the recall session ID to your backend game server so it can query\n // for an existing linked in-game account.\n // - If you discover an existing linked in-game account, continue to sign-in\n // the in-game account. This provides a seamless cross-device sign-in\n // experience.\n // - If there is not an existing linked in-game account, when the user\n // completes the sign-in using your in-game account system record the\n // account linking with Play Games Services Recall. This helps to provide\n // a seamless cross-device sign-in experience when the user returns on a\n // different device or after re-installing your game on the same device.\n } else {\n // Handle the error\n }\n\n**Step 3**: Process the Recall session ID\n-----------------------------------------\n\nOnce your game has the Recall session ID and has passed it to you backend game\nserver, use the [Play Games server-side REST APIs](/games/services/web/api/rest/v1/recall) to:\n\n- Querying for existing linked in-game accounts using [`recall.retrieveTokens`](/games/services/web/api/rest/v1/recall/retrieveTokens)\n- Add or update linked in-game accounts using [`recall.linkPersona`](/games/services/web/api/rest/v1/recall/linkPersona)\n- Delete linked in-game accounts using [`recall.unlinkPersona`](/games/services/web/api/rest/v1/recall/unlinkPersona)\n\nFor a more detailed guide covering the server-side integration see the\ndocumentation covering how to\n[use the Recall API within your game server](/games/pgs/recall/recall-setup#using-recall)."]]