گفتگوهای اصلاح

این صفحه نحوه رسیدگی به مسائل مربوط به احکام صداقت را شرح می دهد.

هنگامی که یک توکن یکپارچگی درخواست می شود، می توانید یک گفتگوی Google Play را برای کاربر نمایش دهید. وقتی یک یا چند مشکل در حکم یکپارچگی وجود دارد، می‌توانید گفتگو را نمایش دهید. گفتگو در بالای برنامه شما نمایش داده می شود و از کاربران می خواهد که علت مشکل را حل کنند. پس از بسته شدن گفتگو، می توانید تأیید کنید که مشکل با یک درخواست دیگر به Integrity API برطرف شده است.

یک گفتگوی یکپارچگی را درخواست کنید

هنگامی که مشتری یک توکن یکپارچگی درخواست می کند، می توانید از روش ارائه شده در StandardIntegrityToken (API استاندارد) و IntegrityTokenResponse (API کلاسیک) استفاده کنید: showDialog(Activity activity, int integrityDialogTypeCode) .

مراحل زیر نحوه استفاده از Play Integrity API را برای نشان دادن گفتگوی اصلاح با استفاده از کد گفتگوی GET_LICENSED نشان می دهد. سایر کدهای محاوره ای که برنامه شما می تواند درخواست کند پس از این بخش فهرست شده اند.

  1. یک توکن یکپارچگی از برنامه خود درخواست کنید و توکن را به سرور خود ارسال کنید. می توانید از درخواست استاندارد یا کلاسیک استفاده کنید.

    کاتلین

    // 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())  

    جاوا

    // 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());  

    وحدت

    // 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); 

    موتور غیر واقعی

    // 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));
  2. در سرور خود، رمز یکپارچگی را رمزگشایی کنید و قسمت appLicensingVerdict بررسی کنید. می تواند چیزی شبیه به این باشد:

    // Licensing issue
    {
      ...
      "accountDetails": {
          "appLicensingVerdict": "UNLICENSED"
      }
    }
  3. اگر توکن حاوی appLicensingVerdict: "UNLICENSED" است، به مشتری برنامه خود پاسخ دهید و از آن درخواست کنید گفتگوی مجوز را نشان دهد:

    کاتلین

    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
    }

    جاوا

    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;
    }

    وحدت

    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;
    } 

    موتور غیر واقعی

    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;
    }
  4. در برنامه خود، با showDialog با کد درخواستی بازیابی شده از سرور تماس بگیرید:

    کاتلین

    // 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.
    } 

    جاوا

    // 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.
    }

    وحدت

    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.
    } 

    موتور غیر واقعی

    // .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.
    }
  5. گفتگو در بالای فعالیت ارائه شده نمایش داده می شود. هنگامی که کاربر گفتگو را بسته است، Task با یک کد پاسخ کامل می شود.

  6. (اختیاری) برای نمایش هر دیالوگ بیشتر، توکن دیگری درخواست کنید. اگر درخواست‌های استاندارد ارائه می‌کنید، باید دوباره ارائه‌دهنده توکن را گرم کنید تا یک حکم جدید دریافت کنید.

کدهای محاوره ای یکپارچگی

GET_LICENSED (نوع کد 1)

موضوع حکم

این گفتگو برای دو موضوع مناسب است:

  • دسترسی غیرمجاز : appLicensingVerdict: "UNLICENSED" . این به این معنی است که حساب کاربری برای برنامه شما حقی ندارد، که اگر کاربر آن را از طرفی بارگذاری کند یا آن را از یک فروشگاه برنامه متفاوت از Google Play خریداری کند، ممکن است اتفاق بیفتد.
  • برنامه دستکاری شده : appRecognitionVerdict: "UNRECOGNIZED_VERSION" . این بدان معنی است که باینری برنامه شما تغییر یافته است یا نسخه ای نیست که توسط Google Play شناسایی شده است.

اصلاح

می‌توانید گفتگوی GET_LICENSED را نشان دهید تا از کاربر بخواهید برنامه اصلی را از Google Play خریداری کند. این گفتگوی واحد به هر دو سناریو می پردازد:

  • برای یک کاربر بدون مجوز ، به آنها مجوز Play می دهد. این به کاربر امکان می‌دهد به‌روزرسانی‌های برنامه را از Google Play دریافت کند.
  • برای کاربری با نسخه برنامه دستکاری شده ، آنها را به نصب برنامه تغییر نیافته از Google Play راهنمایی می کند.

وقتی کاربر گفتگو را کامل کرد، بررسی‌های یکپارچگی بعدی appLicensingVerdict: "LICENSED" و appRecognitionVerdict: "PLAY_RECOGNIZED" را برمی‌گرداند.

مثال UX

شکل 1. گفتگوی پخش GET_LICENSED.

CLOSE_UNKNOWN_ACCESS_RISK (نوع کد 2)

موضوع حکم

وقتی environmentDetails.appAccessRiskVerdict.appsDetected حاوی "UNKNOWN_CAPTURING" یا "UNKNOWN_CONTROLLING" باشد، به این معنی است که برنامه‌های ناشناخته‌ای در دستگاه در حال اجرا هستند که می‌توانند صفحه نمایش را بگیرند یا دستگاه را کنترل کنند.

اصلاح

می‌توانید کادر گفتگوی CLOSE_UNKNOWN_ACCESS_RISK را نشان دهید تا از کاربر بخواهد همه برنامه‌های ناشناخته‌ای را که می‌توانند صفحه نمایش را گرفته یا دستگاه را کنترل کنند، ببندد. اگر کاربر روی دکمه Close all ضربه بزند، همه این برنامه ها بسته می شوند.

مثال UX

شکل 2. گفتگو برای خطر دسترسی ناشناخته نزدیک.

CLOSE_ALL_ACCESS_RISK (نوع کد 3)

موضوع حکم

وقتی environmentDetails.appAccessRiskVerdict.appsDetected حاوی هر یک از "KNOWN_CAPTURING" ، "KNOWN_CONTROLLING" ، "UNKNOWN_CAPTURING" یا "UNKNOWN_CONTROLLING" باشد، به این معنی است که برنامه هایی روی دستگاه در حال اجرا هستند که می توانند صفحه نمایش را کنترل کنند.

اصلاح

می‌توانید کادر گفتگوی CLOSE_ALL_ACCESS_RISK را نشان دهید تا از کاربر بخواهد همه برنامه‌هایی را که می‌توانند صفحه نمایش را ضبط کرده یا دستگاه را کنترل کنند، ببندد. اگر کاربر روی دکمه Close all ضربه بزند، همه این برنامه‌ها روی دستگاه بسته می‌شوند.

مثال UX

شکل 3. گفتگو برای بستن تمام خطر دسترسی.