Auf dieser Seite wird beschrieben, wie Sie Probleme mit Integritätsurteilen beheben.
Wenn ein Integritätstoken angefordert wird, können Sie dem Nutzer ein Google Play-Dialogfeld anzeigen. Sie können das Dialogfeld anzeigen, wenn ein oder mehrere Probleme mit dem Integritätsurteil vorliegen. Das Dialogfeld wird über Ihrer App angezeigt und fordert Nutzer auf, die Ursache des Problems zu beheben. Sobald das Dialogfeld geschlossen ist, können Sie mit einer weiteren Anfrage an die Integrity API prüfen, ob das Problem behoben wurde.
Integritätsdialogfeld anfordern
Wenn der Client ein Integritätstoken anfordert, können Sie die Methode verwenden, die in StandardIntegrityToken (Standard-API) und IntegrityTokenResponse (Classic API) angeboten wird: showDialog(Activity activity, int integrityDialogTypeCode)
.
In den folgenden Schritten wird beschrieben, wie Sie mit der Play Integrity API einen Korrekturdialog mit dem Dialogcode GET_LICENSED anzeigen können. Andere Dialogcodes, die Ihre App anfordern kann, sind nach diesem Abschnitt aufgeführt.
Fordern Sie ein Integritätstoken von Ihrer App an und senden Sie es an Ihren Server. Sie können die Standard- oder die klassische Anfrage verwenden.
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);
Nativ
/// 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));
Entschlüsseln Sie das Integritätstoken auf Ihrem Server und prüfen Sie das Feld
appLicensingVerdict
. Das könnte so aussehen:// Licensing issue { ... accountDetails: { appLicensingVerdict: "UNLICENSED" } }
Wenn das Token
appLicensingVerdict: "UNLICENSED"
enthält, antworten Sie Ihrem App-Client und fordern Sie ihn auf, den Lizenzierungsdialog anzuzeigen: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; }
Nativ
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; }
Rufen Sie in Ihrer App
showDialog
mit dem angeforderten Code auf, der von Ihrem Server abgerufen wurde: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); }
Nativ
// 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. }
Das Dialogfeld wird über der angegebenen Aktivität angezeigt. Wenn der Nutzer das Dialogfeld geschlossen hat, wird die Aufgabe mit einem Antwortcode abgeschlossen.
Optional: Fordern Sie ein weiteres Token an, um weitere Dialogfelder anzuzeigen. Wenn Sie Standardanfragen stellen, müssen Sie den Tokenanbieter noch einmal aufwärmen, um ein neues Ergebnis zu erhalten.
Integritätsdialogcodes
GET_LICENSED (Typcode 1)
Problem mit der Einstufung
Dieses Dialogfeld ist für zwei Probleme geeignet:
- Unbefugter Zugriff:
appLicensingVerdict: "UNLICENSED"
. Das bedeutet, dass das Nutzerkonto keine Berechtigung für Ihre App hat. Das kann passieren, wenn der Nutzer die App per Sideload oder über einen anderen App-Shop als Google Play heruntergeladen hat. - Manipulierte App:
appRecognitionVerdict: "UNRECOGNIZED_VERSION"
. Das bedeutet, dass das Binärprogramm Ihrer App geändert wurde oder keine Version ist, die von Google Play erkannt wird.
Auflösung
Sie können das GET_LICENSED
-Dialogfeld anzeigen, um den Nutzer aufzufordern, die Original-App bei Google Play herunterzuladen. Dieses einzelne Dialogfeld deckt beide Szenarien ab:
- Für einen nicht lizenzierten Nutzer wird eine Play-Lizenz gewährt. So kann der Nutzer App-Updates von Google Play erhalten.
- Nutzer mit einer manipulierten App-Version werden aufgefordert, die unveränderte App aus Google Play zu installieren.
Wenn der Nutzer den Dialog abschließt, geben nachfolgende Integritätsprüfungen appLicensingVerdict: "LICENSED"
und appRecognitionVerdict: "PLAY_RECOGNIZED"
zurück.
Beispiel für die Benutzeroberfläche

CLOSE_UNKNOWN_ACCESS_RISK (Typcode 2)
Problem mit der Einstufung
Wenn environmentDetails.appAccessRiskVerdict.appsDetected
"UNKNOWN_CAPTURING"
oder "UNKNOWN_CONTROLLING"
enthält, bedeutet das, dass unbekannte Apps auf dem Gerät ausgeführt werden, die möglicherweise den Bildschirm aufnehmen oder das Gerät steuern.
Auflösung
Sie können das CLOSE_UNKNOWN_ACCESS_RISK
-Dialogfeld anzeigen, um den Nutzer aufzufordern, alle unbekannten Apps zu schließen, die den Bildschirm aufzeichnen oder das Gerät steuern könnten.
Wenn der Nutzer auf die Schaltfläche Close all
tippt, werden alle diese Apps geschlossen.
Beispiel für die Benutzeroberfläche

CLOSE_ALL_ACCESS_RISK (Typcode 3)
Problem mit der Einstufung
Wenn environmentDetails.appAccessRiskVerdict.appsDetected
eines der folgenden Elemente enthält: "KNOWN_CAPTURING"
, "KNOWN_CONTROLLING"
, "UNKNOWN_CAPTURING"
oder "UNKNOWN_CONTROLLING"
, bedeutet das, dass auf dem Gerät Apps ausgeführt werden, die den Bildschirm aufzeichnen oder das Gerät steuern könnten.
Auflösung
Sie können das CLOSE_ALL_ACCESS_RISK
-Dialogfeld anzeigen, um den Nutzer aufzufordern, alle Apps zu schließen, die den Bildschirm aufzeichnen oder das Gerät steuern könnten. Wenn der Nutzer auf die Schaltfläche Close all
tippt, werden alle diese Apps auf dem Gerät geschlossen.
Beispiel für die Benutzeroberfläche
