선택사항인 Firebase 앱 배포 iOS 및 Android SDK를 사용하면 앱의 새 빌드를 설치할 수 있게 될 때 테스터에게 인앱 알림을 표시할 수 있습니다. 이 가이드에서는 앱 배포 iOS 및 Android SDK를 사용하여 테스터를 위한 새 빌드 알림을 만들고 맞춤설정하는 방법을 설명합니다.
시작하기 전에
아직 추가하지 않았다면 iOS 프로젝트에 Firebase를 추가합니다.
1단계: App Distribution Tester API 사용 설정
Google Cloud Console에서 프로젝트를 선택합니다.
Firebase App Testers API에서 사용 설정을 클릭합니다.
2단계: 앱에 앱 배포 추가
프로젝트용으로 만든 Podfile을 열거나
pod init
을 실행하여 Podfile을 만든 후 대상 섹션 안에 다음 줄을 추가합니다.pod 'FirebaseAppDistribution'
podfile 디렉터리에서
pod install
을 실행한 다음 만든.xcworkspace
파일을 엽니다.App
구조체 또는UIApplicationDelegate
에서 Firebase 모듈을 가져옵니다.Swift
import FirebaseCore import FirebaseAppDistribution
Objective-C
@import FirebaseCore; @import FirebaseAppDistribution;
앱 대리자의
application(_:didFinishLaunchingWithOptions:)
메서드에서FirebaseApp
공유 인스턴스를 구성합니다.Swift
// Use Firebase library to configure APIs FirebaseApp.configure()
Objective-C
// Use Firebase library to configure APIs [FIRApp configure];
재구성이 사용 중지된 경우 열려 있는 URL을
application(_:open:options:)
구현의 앱 배포 SDK에 전달합니다.Swift
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { if AppDistribution.appDistribution().application(application, open: url, options: options) { return true } // Handle other non-Firebase URLs here. return false }
Objective-C
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options { if ([[FIRAppDistribution appDistribution] application:app openURL:url options:options]) { return YES; } // Handle other non-Firebase URLs here. return NO; }
마지막으로 앱을 다시 컴파일합니다.
3단계: 인앱 알림 구성
앱 배포 SDK는 테스터를 위한 인앱 빌드 알림을 설정하는 두 가지 방법, 즉 테스터에게 표시할 사전 빌드된 앱 업데이트 및 로그인 대화상자와 함께 제공되는 기본 알림 구성과 자체 사용자 인터페이스를 맞춤설정할 수 있는 고급 알림 구성을 제공합니다. 앱 배포 SDK를 처음 사용하는 경우에는 먼저 기본 알림 구성을 사용하는 것이 좋습니다.
기본 구성
checkForUpdate
를 사용하여 아직 알림을 사용 설정하지 않은 테스터에게 사전 빌드된 알림 사용 설정 대화상자를 표시한 다음 새 빌드를 사용할 수 있는지 확인합니다. 이 메서드를 호출하면 다음과 같은 순서가 적용됩니다.
Google 계정으로 앱 배포에 로그인하라는 메시지를 표시하여 테스터가 알림을 사용 설정했는지 확인합니다.
테스터가 아직 알림을 사용 설정하지 않은 경우 사전 빌드된 대화상자를 표시합니다.
알림 사용 설정은 테스트 기기에서 한 번만 진행하면 되며 앱 업데이트 전반에서 유지됩니다. 알림은 앱이 제거되거나
signOutTester
메서드가 호출될 때까지 테스트 기기에서 사용 설정된 상태로 유지됩니다. 자세한 내용은 메서드의 참조 문서(Swift 또는 Objective-C)를 참조하세요.테스터가 설치할 수 있는 최신 빌드를 확인합니다.
언제든지 앱에서 checkForUpdate()
를 호출할 수 있습니다. 예를 들어 앱 루트 보기의 onAppear(perform:)
에 checkForUpdate()
를 포함하여 시작 시 테스터에게 최신 빌드를 설치하라는 메시지를 표시할 수 있습니다.
다음 예시에서는 테스터가 알림을 사용 설정했는지, 새 빌드에 액세스할 수 있는지 여부를 확인한 후 모두 해당한다면 빌드를 설치할 수 있을 때 대화상자를 표시합니다.
Swift
AppDistribution.appDistribution().checkForUpdate(completion: { release, error in
if error != nil {
// Handle error
return
}
guard let release = release else {
return
}
// Customize your alerts here.
let title = "New Version Available"
let message = "Version \(release.displayVersion)(\(release.buildVersion)) is available."
let uialert = UIAlertController(title: title,message: message, preferredStyle: .alert)
uialert.addAction(UIAlertAction(title: "Update", style: UIAlertAction.Style.default) {
_ in
UIApplication.shared.open(release.downloadURL)
})
uialert.addAction(UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel) {
_ in
})
// self should be a UIViewController.
self.present(uialert, animated: true, completion: nil)
})
Objective-C
[[FIRAppDistribution appDistribution]
checkForUpdateWithCompletion:^(FIRAppDistributionRelease *_Nullable release,
NSError *_Nullable error) {
if (error) {
// Handle error
return;
}
if (release) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"New Version Available"
message:[NSString stringWithFormat:@"Version %@ (%@) is available.", release.displayVersion,
release.buildVersion] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *updateAction = [UIAlertAction actionWithTitle:@"Update"
style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:release.downloadURL options:@{}
completionHandler:nil];
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];
[alert addAction:updateAction];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
}
}];
고급 구성
signInTester()
및 isTesterSignedIn
메서드를 사용하면 테스터의 로그인 환경을 더 유연하게 맞춤설정할 수 있으므로 앱의 모양과 느낌에 더 적합하게 만들 수 있습니다.
다음 예시에서는 테스터가 Firebase 앱 배포 테스터 계정에 이미 로그인되어 있는지 여부를 확인합니다. 따라서 아직 로그인하지 않은 테스터에 대해서만 로그인 UI를 표시할 수 있습니다. 테스터가 로그인하면 checkForUpdate()
를 호출하여 테스터가 새로운 빌드에 액세스할 수 있는지 확인할 수 있습니다.
Swift
// Sign in a tester without automatically checking for update
if (!AppDistribution.appDistribution().isTesterSignedIn) {
AppDistribution.appDistribution().signInTester (completion: { error in
// completion block for signInTester
if (error != nil) {
// handle failed sign in
return
}
// handle successful sign in
})
}
// Only check for update if tester is already signed in - do not prompt
if (AppDistribution.appDistribution().isTesterSignedIn) {
AppDistribution.appDistribution().checkForUpdate(completion: { release, error in
// completion block for check for update
})
}
Objective-C
// Sign in a tester without automatically checking for update
if(![[FIRAppDistribution appDistribution] isTesterSignedIn]) {
[[FIRAppDistribution appDistribution]
signInTesterWithCompletion:^(NSError *_Nullable error) {
// completion block for signInTester
if (error) {
// handle failed sign in
return;
}
// handle successful sign in
}];
}
// only check for update if tester is already signed in - do not prompt
if([[FIRAppDistribution appDistribution] isTesterSignedIn]) {
[[FIRAppDistribution appDistribution]
checkForUpdateWithCompletion:^(FIRAppDistributionRelease *_Nullable release,
NSError *_Nullable error) {
// completion block for check for update
}];
}
signOutTester()
를 비롯한 추가 메서드에 대한 자세한 내용은 Swift 및 Objective-C의 앱 배포 참조 문서를 확인하세요.
4단계: 구현 빌드 및 테스트
마지막으로 Firebase Console을 사용하여 테스터에 빌드를 배포하는 방식으로 앱을 빌드하고 구현을 테스트합니다.
다음과 같은 일반적인 문제에 대한 도움말은 앱 배포 문제 해결 가이드를 참조하세요.
- 테스터가 인앱 알림을 받지 못함
- 테스터에게 Google에 로그인하라는 메시지가 두 번 이상 표시됨