Dialogfelder zur Abhilfe

Auf dieser Seite wird beschrieben, wie Sie Probleme mit Integritätsurteilen behandeln.

Wenn ein Integritätstoken angefordert wird, können Sie dem Nutzer ein Google Play-Dialogfeld anzeigen. Sie können das Dialogfeld anzeigen lassen, wenn es mindestens ein Problem mit dem Integritätsgrad gibt. 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 ist.

Integritätsdialog anfordern

Wenn der Client ein Integritätstoken anfordert, kannst du die Methode verwenden, die in StandardIntegrityToken (Standard API) und IntegrityTokenResponse (klassische API) angeboten wird: showDialog(Activity activity, int integrityDialogTypeCode).

In den folgenden Schritten wird beschrieben, wie Sie mit der Play Integrity API ein Dialogfeld zur Abhilfe mit dem Dialogcode GET_LICENSED anzeigen. Weitere Dialogcodes, die Ihre App anfordern kann, sind nach diesem Abschnitt aufgeführt.

  1. 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));
  2. Entschlüssele das Integritätstoken auf deinem Server und prüfe das Feld appLicensingVerdict. Das könnte so aussehen:

    // Licensing issue
    {
      ...
      accountDetails: {
          appLicensingVerdict: "UNLICENSED"
      }
    }
  3. Wenn das Token appLicensingVerdict: "UNLICENSED" enthält, antworte auf deinen App-Client und bitte ihn, das Lizenzierungsdialogfeld 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;
    }
  4. 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.
    }
  5. Das Dialogfeld wird über der angegebenen Aktivität angezeigt. Wenn der Nutzer das Dialogfeld geschlossen hat, wird die Aufgabe mit einem Antwortcode abgeschlossen.

  6. Optional: Fordere ein weiteres Token an, um weitere Dialogfelder anzuzeigen. Wenn Sie Standardanfragen stellen, müssen Sie den Tokenanbieter noch einmal aufwärmen, um ein neues Urteil zu erhalten.

Integritätsdialogcodes

GET_LICENSED (Typcode 1)

Problem mit der Einstufung

Wenn appLicensingVerdict == "UNLICENSED". Das bedeutet, dass das Nutzerkonto nicht lizenziert ist. Er hat die App also nicht bei Google Play installiert oder gekauft.

Auflösung

Sie können das Dialogfeld GET_LICENSED anzeigen, um den Nutzer dazu aufzufordern, Ihre App bei Google Play herunterzuladen. Wenn der Nutzer zustimmt, wird das Nutzerkonto lizenziert (appLicensingVerdict == "LICENSED"). Die App wird der Google Play-Mediathek des Nutzers hinzugefügt und Google Play kann App-Updates in Ihrem Namen bereitstellen.

Beispiel für UX

GET_LICENSED-Play-Dialogfeld

CLOSE_UNKNOWN_ACCESS_RISK (Typcode 2)

Problem mit der Einstufung

Wenn environmentDetails.appAccessRiskVerdict.appsDetected "UNKNOWN_CAPTURING" oder "UNKNOWN_CONTROLLING" enthält, werden auf dem Gerät unbekannte Apps ausgeführt, die möglicherweise den Bildschirm aufzeichnen 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 erfassen 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 UX

Dialogfeld zum Schließen des Risikos für unbekannte Zugriffe

CLOSE_ALL_ACCESS_RISK (Typcode 3)

Problem mit der Einstufung

Wenn environmentDetails.appAccessRiskVerdict.appsDetected eine der Zeichenfolgen "KNOWN_CAPTURING", "KNOWN_CONTROLLING", "UNKNOWN_CAPTURING" oder "UNKNOWN_CONTROLLING" enthält, werden auf dem Gerät Apps ausgeführt, die den Bildschirm aufzeichnen oder das Gerät steuern könnten.

Auflösung

Sie können das Dialogfeld CLOSE_ALL_ACCESS_RISK 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 UX

Dialogfeld für das Risiko „Alle Zugriffe schließen“