可选的火力地堡应用发布iOS和Android的SDK让你显示应用程序内提醒您测试新版本的应用程式时,可以进行安装。本指南介绍了如何使用App分发iOS和Android SDK来创建和定制新建警报您的测试人员。
在你开始之前
如果你还没有,添加火力地堡到iOS项目。
第1步:启用应用程序分布测试仪API
选择在你的项目中谷歌云端控制台。
在火力地堡测试这些应用API ,点击启用。
第2步:应用分发添加到您的应用程序
打开你的项目创建的Podfile(或运行
pod init
创建一个),然后添加目标区间内以下行:pod 'FirebaseAppDistribution'
在你podfile的目录,运行
pod install
,然后打开创建.xcworkspace
文件。编码您的谷歌应用程序ID(仅适用于iOS版本9和10必填项):
编码您的谷歌应用程序ID
添加
appdistribution-<encoded-google-app-id>
通过在你的代码片段URL方案Info.plist file
(请参阅苹果的文档,了解如何添加在Xcode的URL方案的说明):<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>
然后,用破折号(替换冒号(:)编码您的谷歌应用程序ID - )。请注意,您的谷歌应用程序ID位于您
GoogleService-Info.plist
文件。例如,如果你的谷歌应用程序ID是:7:77777777777:ios:123456789
您的编码谷歌应用程序ID是:
7-77777777777-ios-123456789
导入火力地堡模块在你的
App
结构或UIApplicationDelegate
:迅速
import FirebaseCore
Objective-C
@import FirebaseCore;
配置一个
FirebaseApp
共享实例,通常在你的App
的初始化或应用程序委托的application(_:didFinishLaunchingWithOptions:)
方法:迅速
// Use Firebase library to configure APIs FirebaseApp.configure()
Objective-C
// Use Firebase library to configure APIs [FIRApp configure];
最后,重新编译应用程序。
步骤3 :配置应用程序内的警报
该应用发布SDK提供了应用程序内为您的测试设置生成警报的方式有两种:基本警报配置,其配备了预建的应用程序更新及登录对话,以显示给测试人员,以及先进的警报配置,这使得您自定义自己的用户界面。我们建议首先使用基本警报配置,如果你是新来的应用发布SDK。
基本配置
使用的checkForUpdate
显示预建的启用对谁尚未启用警报测试警报对话,然后检查是否有新版本可用。调用时,法颁布顺序如下:
检查测试人员已经促使他们登录到应用程序分发与他们的谷歌帐户启用警报。
如果测试仪尚未启用警报,显示预建的对话。
启用警报是在您的应用程序的更新测试装置并持续在一个一次性的过程。直到该应用被卸载警报保持在测试设备上启用,或直到
signOutTester
方法被调用。看到该方法的参考文献(夫特或Objective-C的获得更多信息)。对新获得的检查建立的测试安装。
您可以调用的checkForUpdate()
在您的应用程序的任何一点。例如,您可以提示您的测试安装由包括新的可用版本在启动时的checkForUpdate()
在onAppear(perform:)
你的应用程序的根视图。
下面的示例检查测试仪是否已启用警报和访问到新版本,如果是这样,时显示在构建可用于安装对话:
迅速
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
给你更多的灵活性,自定义测试仪的登录体验,因此它可以更好地满足您的应用程序的外观和感觉。
下面的示例检查测试仪是否已经签订到他们的火力地堡应用发布测试帐户,这样你就可以选择只对谁尚未登录测试显示您的登录界面,测试者在签订之后,你就可以调用的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
})
}
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()
,请参阅该应用分发参考文档夫特和目标C 。
第4步:构建和测试您的实现
最后,建立自己的应用程序,并通过测试的实施分发构建使用火力地堡控制台测试。
访问应用程序分发故障排除指南与常见问题,帮助,例如:
- 测试仪没有收到应用程序内的警报
- 测试仪被提示登录到谷歌不止一次