检测是否从 Apple 的 Testflight 下载了 iOS 应用程序

检测是否从 Apple 的 Testflight 下载了 iOS 应用程序

问题描述:

过去,我为通过 TestFlight 分发的生产和 Beta 版本使用了单独的构建配置.这样可以轻松修改 Beta 版本,例如公开应用的其他设置,让测试人员更彻底地测试事物并查看有关应用状态的更多技术信息.

In the past I've had separate build configurations for production and beta builds distributed through TestFlight. This made it easy to make modifications to beta builds, such as exposing additional settings the app to let testers test things more thoroughly and see more technical information about the status of the app.

有没有办法检查应用程序是否已通过 Apple 的 TestFlight 分发以更改应用程序的运行方式?编译器指令不再有意义,因为相同的构建可以分发给 Beta 测试人员并提交给商店,但也许有一种方法可以在运行时进行检查.

Is there a way to check if an app has been distributed through Apple's TestFlight to make changes to how the app runs? Compiler directives no longer make sense as the same build can be distributed to beta testers and submitted to the store, but perhaps there's a way to check at runtime.

这有效:

if ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
    // TestFlight
} else {
    // App Store (and Apple reviewers too)
}

更新

上述方法似乎不再有效,Apple 改变了他们签署 TestFlight 版本的方式.但这确实有效:

The above method doesn't seem to work anymore, Apple changed the way they sign TestFlight builds. This does work however:

BOOL isRunningTestFlightBeta = [[[[NSBundle mainBundle] appStoreReceiptURL] lastPathComponent] isEqualToString:@"sandboxReceipt"];