선택적 Firebase 앱 배포 iOS 및 Android SDK를 사용하면 앱의 새 빌드를 설치할 수 있을 때 테스터에게 인앱 알림을 표시할 수 있습니다. 이 가이드에서는 앱 배포 iOS 및 Android SDK를 사용하여 테스터를 위한 새 빌드 알림을 만들고 사용자 지정하는 방법을 설명합니다.
시작하기 전에
아직 iOS 프로젝트에 Firebase를 추가 하지 않았다면 추가합니다.
1단계 : 앱 배포 테스터 API 활성화
Google Cloud Console 에서 프로젝트를 선택합니다.
Firebase App Testers API 아래에서 사용 을 클릭합니다.
2단계 : 앱에 앱 배포 추가
프로젝트에 대해 생성한 Podfile을 열고(또는
pod init
를 실행하여 생성) 대상 섹션 내에 다음 줄을 추가합니다.pod 'FirebaseAppDistribution'
podfile의 디렉터리에서
pod install
을 실행한 다음 생성된.xcworkspace
파일을 엽니다.Google 앱 ID 인코딩( iOS 버전 9 및 10에만 필요 ):
Google 앱 ID 인코딩
Info.plist file
에 스니펫을 포함하여appdistribution-<encoded-google-app-id>
URL 체계를 추가합니다(Xcode에 URL 체계를 추가하는 방법에 대한 지침은 Apple 설명서 참조).<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>appdistribution-<encoded-google-app-id></string> </array> </dict> </array>
그런 다음 콜론(:)을 대시(-)로 바꿔 Google 앱 ID를 인코딩합니다. Google 앱 ID는
GoogleService-Info.plist
파일에 있습니다. 예를 들어 Google 앱 ID가 다음과 같은 경우:7:77777777777:ios:123456789
인코딩된 Google 앱 ID는 다음과 같습니다.
7-77777777777-ios-123456789
App
구조체 또는UIApplicationDelegate
에서 Firebase 모듈을 가져옵니다.빠른
import FirebaseCore
오브젝티브-C
@import FirebaseCore;
일반적으로
App
이니셜라이저 또는 앱 대리자의application(_:didFinishLaunchingWithOptions:)
메서드에서FirebaseApp
공유 인스턴스를 구성합니다.빠른
// Use Firebase library to configure APIs FirebaseApp.configure()
오브젝티브-C
// Use Firebase library to configure APIs [FIRApp configure];
마지막으로 앱을 다시 컴파일합니다.
3단계 : 인앱 알림 구성
앱 배포 SDK는 테스터를 위한 인앱 빌드 알림을 설정하는 두 가지 방법을 제공합니다. 하나는 테스터에게 표시할 사전 빌드된 앱 업데이트 및 로그인 대화 상자와 함께 제공되는 기본 알림 구성이고 다른 하나는 테스터에게 표시할 수 있는 고급 알림 구성입니다. 자신의 사용자 인터페이스를 사용자 정의할 수 있습니다. 앱 배포 SDK를 처음 사용하는 경우 먼저 기본 경고 구성을 사용하는 것이 좋습니다.
기본 구성
checkForUpdate
를 사용하여 아직 알림을 활성화하지 않은 테스터에게 미리 빌드된 알림 활성화 대화 상자를 표시한 다음 새 빌드를 사용할 수 있는지 확인합니다. 호출되면 메서드는 다음 시퀀스를 적용합니다.
테스터가 Google 계정으로 앱 배포에 로그인하라는 메시지를 표시하여 알림을 활성화했는지 확인합니다.
테스터가 아직 경고를 활성화하지 않은 경우 사전 구축된 대화를 표시합니다.
경고 활성화는 테스트 장치에서 일회성 프로세스이며 앱 업데이트 동안 지속됩니다. 앱이 제거되거나
signOutTester
메서드가 호출될 때까지 테스트 장치에서 경고가 활성화된 상태로 유지됩니다. 자세한 내용은 메서드의 참조 문서( Swift 또는 Objective-C )를 참조하세요.테스터가 설치할 새로 사용 가능한 빌드를 확인합니다.
앱의 어느 지점에서든 checkForUpdate()
를 호출할 수 있습니다. 예를 들어 앱 루트 보기의 onAppear(perform:)
에 checkForUpdate()
를 포함하여 시작 시 테스터에게 새로 사용 가능한 빌드를 설치하도록 요청할 수 있습니다.
다음 예는 테스터가 경고를 활성화하고 새 빌드에 액세스할 수 있는지 여부를 확인하고, 그렇다면 빌드를 설치할 수 있을 때 대화 상자를 표시합니다.
빠른
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)
})
오브젝티브-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()
를 호출하여 테스터가 새 빌드에 액세스할 수 있는지 확인합니다.
빠른
// 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
})
}
오브젝티브-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 콘솔을 사용하여 테스터 에게 빌드를 배포 하여 앱을 빌드하고 구현을 테스트합니다.
다음과 같은 일반적인 문제에 대한 도움을 받으려면 앱 배포 문제 해결 가이드 를 방문하세요.
- 테스터가 인앱 알림을 수신하지 않음
- 테스터에게 Google에 두 번 이상 로그인하라는 메시지가 표시됨