หน้านี้จะอธิบายวิธีจัดการปัญหาเกี่ยวกับผลการตรวจสอบความสมบูรณ์
เมื่อมีการขอโทเค็นความสมบูรณ์ คุณจะมีตัวเลือกในการแสดงกล่องโต้ตอบ Google Play ต่อผู้ใช้ คุณอาจแสดงกล่องโต้ตอบเมื่อมีอย่างน้อย 1 ปัญหาเกี่ยวกับผลการตรวจสอบความสมบูรณ์ กล่องโต้ตอบจะแสดงที่ด้านบนของแอป และแจ้งให้ผู้ใช้แก้ไขสาเหตุของปัญหา เมื่อปิดกล่องโต้ตอบแล้ว คุณสามารถยืนยันได้ว่าปัญหาได้รับการแก้ไขแล้วด้วยคำขออีกรายการใน Integrity API
กล่องโต้ตอบความสมบูรณ์
GET_LICENSED (รหัสประเภท 1)
ปัญหาเกี่ยวกับคำตัดสิน
เมื่อappLicensingVerdict == "UNLICENSED"
ซึ่งหมายความว่าบัญชีผู้ใช้ไม่มีใบอนุญาต กล่าวคือ ผู้ใช้ไม่ได้ติดตั้งหรือซื้อแอปจาก Google Play
การแก้ไข
คุณสามารถแสดงกล่องโต้ตอบ GET_LICENSED
เพื่อแจ้งให้ผู้ใช้ดาวน์โหลดแอปจาก Google Play หากผู้ใช้ยอมรับ บัญชีของผู้ใช้จะได้รับใบอนุญาต (appLicensingVerdict == "LICENSED"
) ระบบจะเพิ่มแอปลงในคลัง Google Play ของผู้ใช้ และ Google Play สามารถส่งการอัปเดตแอปในนามของคุณ
ตัวอย่าง UX
CLOSE_UNKNOWN_ACCESS_RISK (รหัสประเภท 2)
ปัญหาเกี่ยวกับคำตัดสิน
เมื่อ environmentDetails.appAccessRiskVerdict.appsDetected
มี "UNKNOWN_CAPTURING"
หรือ "UNKNOWN_CONTROLLING"
แสดงว่ามีแอปที่ไม่รู้จักทำงานอยู่ในอุปกรณ์ซึ่งอาจกำลังจับภาพหน้าจอหรือควบคุมอุปกรณ์
การแก้ไข
คุณสามารถแสดงกล่องโต้ตอบ CLOSE_UNKNOWN_ACCESS_RISK
เพื่อแจ้งให้ผู้ใช้ปิดแอปที่ไม่รู้จักทั้งหมดซึ่งอาจจับภาพหน้าจอหรือควบคุมอุปกรณ์
หากผู้ใช้แตะปุ่ม Close all
แอปดังกล่าวทั้งหมดจะปิดลง
ตัวอย่าง UX
CLOSE_ALL_ACCESS_RISK (รหัสประเภท 3)
ปัญหาเกี่ยวกับคำตัดสิน
เมื่อ environmentDetails.appAccessRiskVerdict.appsDetected
มี "KNOWN_CAPTURING"
, "KNOWN_CONTROLLING"
,"UNKNOWN_CAPTURING"
หรือ "UNKNOWN_CONTROLLING"
แสดงว่ามีแอปที่ทำงานอยู่ในอุปกรณ์ซึ่งอาจกำลังจับภาพหน้าจอหรือควบคุมอุปกรณ์
การแก้ไข
คุณสามารถแสดงกล่องโต้ตอบ CLOSE_ALL_ACCESS_RISK
เพื่อแจ้งให้ผู้ใช้ปิดแอปทั้งหมดที่อาจกำลังจับภาพหน้าจอหรือควบคุมอุปกรณ์ หากผู้ใช้แตะปุ่ม Close all
ระบบจะปิดแอปดังกล่าวทั้งหมดในอุปกรณ์
ตัวอย่าง UX
ขอกล่องโต้ตอบความสมบูรณ์
เมื่อไคลเอ็นต์ขอโทเค็นความสมบูรณ์ คุณสามารถใช้เมธอดที่ระบุไว้ใน StandardIntegrityToken (Standard API) และ IntegrityTokenResponse (Classic API) ดังนี้
showDialog(Activity activity, int integrityDialogTypeCode)
ขั้นตอนต่อไปนี้จะอธิบายวิธีใช้ Play Integrity API เพื่อแสดงกล่องโต้ตอบ GET_LICENSED
ขอโทเค็นความสมบูรณ์จากแอป แล้วส่งโทเค็นไปยังเซิร์ฟเวอร์ คุณสามารถใช้คำขอมาตรฐานหรือแบบคลาสสิกได้
Kotlin
// Request an integrity token val tokenResponse: StandardIntegrityToken = requestIntegrityToken() // Send token to app server and get response on what to do next val yourServerResponse: YourServerResponse = sendToServer(tokenResponse.token())
Java
// Request an integrity token StandardIntegrityToken tokenResponse = requestIntegrityToken(); // Send token to app server and get response on what to do next YourServerResponse yourServerResponse = sendToServer(tokenResponse.token());
Unity
// Request an integrity token StandardIntegrityToken tokenResponse = RequestIntegrityToken(); // Send token to app server and get response on what to do next YourServerResponse yourServerResponse = sendToServer(tokenResponse.Token);
Unreal Engine
// Request an integrity token StandardIntegrityToken* Response = RequestIntegrityToken(); // Send token to app server and get response on what to do next YourServerResponse YourServerResponse = SendToServer(Response->Token);
เนทีฟ
/// Request an integrity token StandardIntegrityToken* response = requestIntegrityToken(); /// Send token to app server and get response on what to do next YourServerResponse yourServerResponse = sendToServer(StandardIntegrityToken_getToken(response));
ในเซิร์ฟเวอร์ ให้ถอดรหัสโทเค็นความสมบูรณ์และตรวจสอบช่อง
appLicensingVerdict
ซึ่งอาจมีลักษณะดังนี้// Licensing issue { ... accountDetails: { appLicensingVerdict: "UNLICENSED" } }
หากโทเค็นมี
appLicensingVerdict: "UNLICENSED"
ให้ตอบกลับไคลเอ็นต์แอปเพื่อขอให้แสดงกล่องโต้ตอบการอนุญาตให้ใช้สิทธิ ดังนี้Kotlin
private fun getDialogTypeCode(integrityToken: String): Int{ // Get licensing verdict from decrypted and verified integritytoken val licensingVerdict: String = getLicensingVerdictFromDecryptedToken(integrityToken) return if (licensingVerdict == "UNLICENSED") { 1 // GET_LICENSED } else 0 }
Java
private int getDialogTypeCode(String integrityToken) { // Get licensing verdict from decrypted and verified integrityToken String licensingVerdict = getLicensingVerdictFromDecryptedToken(integrityToken); if (licensingVerdict.equals("UNLICENSED")) { return 1; // GET_LICENSED } return 0; }
Unity
private int GetDialogTypeCode(string IntegrityToken) { // Get licensing verdict from decrypted and verified integrityToken string licensingVerdict = GetLicensingVerdictFromDecryptedToken(IntegrityToken); if (licensingVerdict == "UNLICENSED") { return 1; // GET_LICENSED } return 0; }
Unreal Engine
private int GetDialogTypeCode(FString IntegrityToken) { // Get licensing verdict from decrypted and verified integrityToken FString LicensingVerdict = GetLicensingVerdictFromDecryptedToken(IntegrityToken); if (LicensingVerdict == "UNLICENSED") { return 1; // GET_LICENSED } return 0; }
เนทีฟ
private int getDialogTypeCode(string integrity_token) { /// Get licensing verdict from decrypted and verified integrityToken string licensing_verdict = getLicensingVerdictFromDecryptedToken(integrity_token); if (licensing_verdict == "UNLICENSED") { return 1; // GET_LICENSED } return 0; }
ในแอป ให้โทรหา
showDialog
ด้วยรหัสที่ขอซึ่งดึงมาจากเซิร์ฟเวอร์Kotlin
// Show dialog as indicated by the server val showDialogType: Int? = yourServerResponse.integrityDialogTypeCode() if (showDialogType != null) { // Call showDialog with type code, the dialog will be shown on top of the // provided activity and complete when the dialog is closed. val integrityDialogResponseCode: Task<Int> = tokenResponse.showDialog(activity, showDialogType) // Handle response code, call the Integrity API again to confirm that // verdicts have been resolved. }
Java
// Show dialog as indicated by the server @Nullable Integer showDialogType = yourServerResponse.integrityDialogTypeCode(); if (showDialogType != null) { // Call showDialog with type code, the dialog will be shown on top of the // provided activity and complete when the dialog is closed. Task<Integer> integrityDialogResponseCode = tokenResponse.showDialog(activity, showDialogType); // Handle response code, call the Integrity API again to confirm that // verdicts have been resolved. }
Unity
IEnumerator ShowDialogCoroutine() { int showDialogType = yourServerResponse.IntegrityDialogTypeCode(); // Call showDialog with type code, the dialog will be shown on top of the // provided activity and complete when the dialog is closed. var showDialogTask = tokenResponse.ShowDialog(showDialogType); // Wait for PlayAsyncOperation to complete. yield return showDialogTask; // Handle response code, call the Integrity API again to confirm that // verdicts have been resolved. }
Unreal Engine
// .h void MyClass::OnShowDialogCompleted( EStandardIntegrityErrorCode Error, EIntegrityDialogResponseCode Response) { // Handle response code, call the Integrity API again to confirm that // verdicts have been resolved. } // .cpp void MyClass::RequestIntegrityToken() { UStandardIntegrityToken* Response = ... int TypeCode = YourServerResponse.integrityDialogTypeCode(); // Create a delegate to bind the callback function. FShowDialogStandardOperationCompletedDelegate Delegate; // Bind the completion handler (OnShowDialogCompleted) to the delegate. Delegate.BindDynamic(this, &MyClass::OnShowDialogCompleted); // Call ShowDialog with TypeCode which completes when the dialog is closed. Response->ShowDialog(TypeCode, Delegate); }
เนทีฟ
// Show dialog as indicated by the server int show_dialog_type = yourServerResponse.integrityDialogTypeCode(); if (show_dialog_type != 0) { /// Call showDialog with type code, the dialog will be shown on top of the /// provided activity and complete when the dialog is closed. StandardIntegrityErrorCode error_code = IntegrityTokenResponse_showDialog(response, activity, show_dialog_type); /// Proceed to polling iff error_code == STANDARD_INTEGRITY_NO_ERROR if (error_code != STANDARD_INTEGRITY_NO_ERROR) { /// Remember to call the *_destroy() functions. return; } /// Use polling to wait for the async operation to complete. /// Note, the polling shouldn't block the thread where the IntegrityManager /// is running. IntegrityDialogResponseCode* response_code; error_code = StandardIntegrityToken_getDialogResponseCode(response, response_code); if (error_code != STANDARD_INTEGRITY_NO_ERROR) { /// Remember to call the *_destroy() functions. return; } /// Handle response code, call the Integrity API again to confirm that /// verdicts have been resolved. }
กล่องโต้ตอบจะแสดงที่ด้านบนของกิจกรรมที่ระบุ เมื่อผู้ใช้ปิดกล่องโต้ตอบแล้ว งานจะเสร็จสมบูรณ์พร้อมรหัสคำตอบ
(ไม่บังคับ) ขอโทเค็นอื่นเพื่อแสดงกล่องโต้ตอบเพิ่มเติม หากคุณส่งคำขอมาตรฐาน คุณจะต้องอุ่นเครื่องผู้ให้บริการโทเค็นอีกครั้งเพื่อให้ได้ผลลัพธ์ใหม่