테스터에게 새 빌드에 대해 알림

선택사항인 Firebase 앱 배포 iOS 및 Android SDK를 사용하면 앱의 새 빌드를 설치할 수 있게 될 때 테스터에게 인앱 알림을 표시할 수 있습니다. 이 가이드에서는 앱 배포 iOS 및 Android SDK를 사용하여 테스터를 위한 새 빌드 알림을 만들고 맞춤설정하는 방법을 설명합니다.

시작하기 전에

아직 추가하지 않았다면 Android 프로젝트에 Firebase를 추가합니다.

1단계: App Distribution Tester API 사용 설정

  1. Google Cloud Console에서 프로젝트를 선택합니다.

  2. Firebase App Testers API에서 사용 설정을 클릭합니다.

2단계: 앱에 앱 배포 추가

앱 배포 Android SDK는 2개의 라이브러리로 구성됩니다.

  • firebase-appdistribution-api - 모든 빌드 변형에 포함할 수 있는 API 전용 라이브러리입니다.
  • firebase-appdistribution - 전체 SDK 구현입니다(선택사항).

API 전용 라이브러리에서는 코드가 SDK를 호출할 수 있습니다. 전체 SDK 구현이 없으면 호출이 효과가 없습니다.

모듈(앱 수준) Gradle 파일(일반적으로 <project>/<app-module>/build.gradle.kts 또는 <project>/<app-module>/build.gradle)에 앱 배포 Android SDK 종속 항목을 선언합니다. Play 빌드에 전체 SDK 구현의 자체 업데이트 기능을 포함하지 않으려면 모든 빌드 변형에 API 전용 라이브러리 종속 항목을 추가합니다. 출시 전 테스트에만 사용되는 변형에 전체 SDK 구현을 추가합니다.

Kotlin+KTX

dependencies {
    // ADD the API-only library to all variants
    implementation("com.google.firebase:firebase-appdistribution-api-ktx:16.0.0-beta10")

    // ADD the full SDK implementation to the "beta" variant only (example)
    betaImplementation("com.google.firebase:firebase-appdistribution:16.0.0-beta10")
}

Java

dependencies {
    // ADD the API-only library to all variants
    implementation("com.google.firebase:firebase-appdistribution-api:16.0.0-beta10")

    // ADD the full SDK implementation to the "beta" variant only (example)
    betaImplementation("com.google.firebase:firebase-appdistribution:16.0.0-beta10")
}

3단계: 인앱 알림 구성

앱 배포 Android SDK는 테스터를 위한 인앱 빌드 알림을 설정할 수 있도록 다음과 같은 방법을 제공합니다.

  • 테스터에게 표시할 사전 빌드된 앱 업데이트 및 로그인 대화상자와 함께 제공되는 기본 알림 구성
  • 자체 사용자 인터페이스를 맞춤설정할 수 있는 고급 알림 구성

앱 배포 Android SDK를 처음 사용하는 경우에는 기본 구성을 사용하는 것이 좋습니다.

기본 구성

updateIfNewReleaseAvailable을 사용하여 아직 알림을 사용 설정하지 않은 테스터에게 사전 빌드된 알림 사용 설정 대화상자를 표시한 다음 새 빌드를 사용할 수 있는지 확인합니다. 이 메서드를 호출하면 다음과 같은 순서가 적용됩니다.

  1. 테스터가 알림을 사용 설정했는지 확인합니다. 테스터가 아직 알림을 사용 설정하지 않은 경우 이 메서드가 테스터에게 Google 계정으로 앱 배포에 로그인하라는 메시지를 표시합니다.

  2. 테스터가 설치할 수 있는 최신 빌드를 확인합니다.

  3. 테스터에게 업데이트하라는 사전 빌드된 알림을 표시합니다.

  4. 새 빌드가 Android App Bundle(AAB)인 경우 테스터를 Google Play로 리디렉션하여 업데이트 프로세스를 완료합니다.

    새 빌드가 Android 애플리케이션 패키지(APK)인 경우 SDK가 백그라운드에서 새 빌드를 다운로드하고 다운로드가 완료되면 테스터에게 설치하라는 메시지를 표시합니다. SDK가 NotificationManager를 사용하여 다운로드 진행률 알림을 사용자에게 보냅니다. 또한 updateIfNewReleaseAvailable 태스크에 onProgressUpdate 핸들러를 연결하여 자체 진행률 표시기를 추가할 수도 있습니다.

언제든지 앱에서 updateIfNewReleaseAvailable을 호출할 수 있습니다. 예를 들어 앱 기본 활동의 onResume 메서드 중에 updateIfNewReleaseAvailable을 호출할 수 있습니다.

다음 예시에서는 테스터가 알림을 사용 설정했는지, 새 빌드에 액세스할 수 있는지 확인합니다. 이러한 조건이 충족되면 빌드를 설치할 수 있을 때 대화상자가 표시됩니다.

Kotlin+KTX

// Copy and paste this into any part of your app - for example, in your main
// activity's onResume method.
val firebaseAppDistribution = FirebaseAppDistribution.getInstance()
firebaseAppDistribution.updateIfNewReleaseAvailable()
    .addOnProgressListener { updateProgress ->
      // (Optional) Implement custom progress updates in addition to
      // automatic NotificationManager updates.
    }
    .addOnFailureListener { e ->
      // (Optional) Handle errors.
      if (e is FirebaseAppDistributionException) {
        when (e.errorCode) {
          Status.NOT_IMPLEMENTED -> {
            // SDK did nothing. This is expected when building for Play.
          }
          else -> {
            // Handle other errors.
          }
        }
      }
    }

Java

// Copy and paste this into any part of your app - for example, in your main
// activity's onResume method.
FirebaseAppDistribution firebaseAppDistribution = FirebaseAppDistribution.getInstance();
firebaseAppDistribution.updateIfNewReleaseAvailable()
    .addOnProgressListener(updateProgress -> {
      // (Optional) Implement custom progress updates in addition to
      // automatic NotificationManager updates.
    })
    .addOnFailureListener(e -> {
      // (Optional) Handle errors.
      if (e instanceof FirebaseAppDistributionException) {
        switch (((FirebaseAppDistributionException)e).getErrorCode()) {
          case NOT_IMPLEMENTED:
            // SDK did nothing. This is expected when building for Play.
            break;
          default:
            // Handle other errors.
            break;
        }
      }
    });

고급 구성

고급 로그인 구성

signInTesterisTesterSignedIn 메서드를 사용하면 테스터의 로그인 환경을 더 유연하게 맞춤설정할 수 있으므로 테스터 환경을 앱의 디자인과 분위기에 보다 잘 맞게 만들 수 있습니다.

다음 예시에서는 테스터가 앱 배포 테스터 계정에 이미 로그인했는지 확인합니다. 이렇게 하면 아직 로그인하지 않은 테스터에게만 로그인 사용자 인터페이스(UI)를 표시할 수 있습니다. 테스터가 로그인한 후 updateIfNewReleaseAvailable을 호출하여 테스터가 새로운 빌드에 액세스할 수 있는지 확인할 수 있습니다.

Kotlin+KTX

// Only show sign-in UI if this is the "beta" variant (example).
if (BuildConfig.BUILD_TYPE == "beta" && !firebaseAppDistribution.isTesterSignedIn) {
    // Start your sign-in UI here.
}

// Only check for updates if the tester is already signed in (do not prompt).
if (firebaseAppDistribution.isTesterSignedIn) {
    firebaseAppDistribution.updateIfNewReleaseAvailable().addOnFailureListener {
        // Handle failed update.
    }
}

Java

// Only show sign-in UI if this is the "beta" variant (example).
if (BuildConfig.BUILD_TYPE == "beta" && !firebaseAppDistribution.isTesterSignedIn()) {
    // Start your sign-in UI here.
}

// Only check for updates if the tester is already signed in (do not prompt).
if (firebaseAppDistribution.isTesterSignedIn()) {
    firebaseAppDistribution.updateIfNewReleaseAvailable().addOnFailureListener( e -> {
        // Handle failed update.
    });
}

로그인 UI에서 테스터가 계속 진행을 선택하면 signInTester()를 호출합니다.

Kotlin+KTX

firebaseAppDistribution.signInTester().addOnSuccessListener {
  // Handle successful sign-in.
}.addOnFailureListener {
  // Handle failed sign-in.
});

Java

firebaseAppDistribution.signInTester().addOnSuccessListener( unused -> {
  // Handle successful sign-in.
}).addOnFailureListener(e -> {
  // Handle failed sign-in.
});

고급 업데이트 구성

checkForNewReleaseupdateApp 메서드를 사용하면 테스터에게 업데이트하라는 메시지가 표시되는 시점을 더 유연하게 맞춤설정할 수 있습니다. 또한 사전 빌드된 업데이트 대화상자 및 다운로드 진행률 표시기를 맞춤설정하여 앱의 디자인과 분위기에 보다 잘 맞게 만들 수 있습니다.

updateApp은 다운로드 진행률 표시를 제공하지 않습니다. 즉, 일종의 인앱 상태 표시인 NotificationManager 또는 다른 접근 방식을 사용하여 자체 진행률 표시를 구현해야 합니다.

다음 예시에서는 새 출시 버전을 사용할 수 있는지 확인한 다음 커스텀 UI를 표시합니다. checkForNewReleaseupdateApp을 호출하기 전에 고급 로그인 구성을 사용하여 테스터가 로그인했는지 확인하세요.

Kotlin+KTX

firebaseAppDistribution.checkForNewRelease().addOnSuccessListener { release ->
    if (release != null) {
        // New release available. Start your update UI here.
    }
}.addOnFailureListener {
    // Handle failed check for new release. Fails with Status#NOT_IMPLEMENTED
    // if built for Play.
}

Java

firebaseAppDistribution.checkForNewRelease().addOnSuccessListener(release -> {
    if (release != null) {
        // New release available. Start your update UI here.
    }
}).addOnFailureListener(e -> {
    // Handle failed check for new release. Fails with Status#NOT_IMPLEMENTED
    // if built for Play.
});

테스터가 업데이트 UI에서 업데이트를 계속하도록 선택하면 updateApp()을 호출합니다.

Kotlin+KTX

firebaseAppDistribution.updateApp()
    .addOnProgressListener { updateState ->
      // Use updateState to show update progress.
    }

Java

firebaseAppDistribution.updateApp()
    .addOnProgressListener(updateState -> {
      // Use updateState to show update progress.
    });

4단계: 구현 빌드 및 테스트

Firebase Console을 사용하여 테스터에 빌드를 배포하는 방식으로 앱을 빌드하고 구현을 테스트합니다.

다음과 같은 일반적인 문제에 대한 도움말은 앱 배포 문제 해결 가이드를 참조하세요.

  • 테스터가 인앱 알림을 받지 못함
  • 테스터에게 Google에 로그인하라는 메시지가 두 번 이상 표시됨