ลงชื่อเข้าใช้ผู้ใช้ในเกมได้อย่างราบรื่นขณะใช้ระบบบัญชีของคุณเองต่อไป Play Games Services Recall API ช่วยให้คุณลิงก์บัญชีในเกมกับบัญชีบริการเกมของ Google Play ได้ เมื่อผู้ใช้เล่นเกมในอุปกรณ์ต่างๆ (หรืออุปกรณ์เครื่องเดิมหลังจากติดตั้งเกมอีกครั้ง) คุณจะค้นหาบัญชีในเกมที่ลิงก์ไว้และปรับปรุงขั้นตอนการลงชื่อเข้าใช้ได้
หากคุณผสานรวมกับ Android Recall API อยู่แล้ว Recall API เหล่านี้จะดูคุ้นเคย การผสานรวมฝั่งเซิร์ฟเวอร์กับบริการเกมของ Play Recall สามารถนำมาใช้ซ้ำกับเกมบน PC ได้ เนื่องจากข้อมูลเหมือนกันทั้งใน Android และ PC
ขั้นตอนที่ 1: เพิ่มรหัสโปรเจ็กต์บริการเกมของ Play ในไฟล์ Manifest
หลังจากตั้งค่าบริการเกมของ Play ใน Play Console เสร็จแล้ว ตอนนี้เกมของคุณจะมีรหัสโปรเจ็กต์ของบริการเกมของ Play ที่เชื่อมโยงอยู่ ใช้รหัสโปรเจ็กต์นี้ซึ่งดูได้ในหน้าการกําหนดค่าของบริการ Play Games ใน Play Console เพื่ออัปเดต manifest.xml ของเกม
การเรียกนี้แสดงผลรหัสเซสชันที่แบ็กเอนด์ใช้เพื่อเรียกใช้ Google ฝั่งเซิร์ฟเวอร์เพื่อลิงก์และยกเลิกการลิงก์บัญชีในเกมกับผู้ใช้บริการ Play Games
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 UTC"],[],[],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)."]]