해결

이 페이지에서는 무결성 확인 결과 문제를 처리하는 방법을 설명합니다.

무결성 토큰을 요청할 때 사용자에게 Google Play 대화상자를 표시할 수 있습니다. 무결성 확인 결과에 하나 이상의 문제가 있는 경우 대화상자를 표시할 수 있습니다. 대화상자는 앱 상단에 표시되며 사용자에게 문제의 원인을 해결하라는 메시지를 표시합니다. 대화상자가 닫히면 Integrity API에 대한 또 다른 요청으로 문제가 해결되었는지 확인할 수 있습니다.

무결성 대화상자

GET_LICENSED(유형 코드 1)

확인 결과 문제

appLicensingVerdict == "UNLICENSED"인 경우. 이는 사용자 계정에 라이선스가 부여되지 않았음을 의미합니다. 즉, 사용자가 Google Play에서 앱을 설치하거나 구매하지 않았습니다.

해결

GET_LICENSED 대화상자를 표시하여 사용자에게 Google Play에서 앱을 다운로드하라는 메시지를 표시할 수 있습니다. 사용자가 수락하면 사용자 계정에 라이선스가 부여됩니다(appLicensingVerdict == "LICENSED"). 앱이 사용자의 Google Play 라이브러리에 추가되며 Google Play에서는 개발자 대신 앱 업데이트를 전송할 수 있습니다.

UX 예시

GET_LICENSED Play 대화상자

무결성 요청 대화상자

클라이언트가 무결성 토큰을 요청하면 StandardIntegrityToken(표준 API) 및 IntegrityTokenResponse(기존 API)에 제공된 메서드(showDialog(Activity activity, int integrityDialogTypeCode))를 사용하면 됩니다.

다음 단계에서는 Play Integrity API를 사용하여 GET_LICENSED 대화상자를 표시하는 방법을 간략하게 설명합니다.

  1. 앱에서 무결성 토큰을 요청하고 토큰을 서버로 전송합니다. 표준 또는 기존 요청을 사용할 수 있습니다.

    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());
    
    
  2. 서버에서 무결성 토큰을 복호화하고 appLicensingVerdict 필드를 확인합니다. 다음과 같이 표시될 수 있습니다.

    // Licensing issue
    {
      ...
      accountDetails: {
        appLicensingVerdict: "UNLICENSED"
      }
    }
    
  3. 토큰에 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;
    }
    
    
  4. 서버에서 가져온 요청 코드를 사용하여 앱에서 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.
    }
    
    
  5. 이 대화상자는 제공된 활동 위에 표시됩니다. 사용자가 대화상자를 닫으면 작업은 응답 코드로 완료됩니다.

  6. (선택사항) 추가 대화상자를 표시하려면 또 다른 토큰을 요청합니다. 표준 요청을 하는 경우 토큰 제공자를 다시 준비하여 새로운 확인 결과를 얻어야 합니다.