检查iOS应用是否在应用商店中

人气:359 发布:2022-10-16 标签: ios itunes-sdk itunes ios5 app-store-connect

问题描述

是否可以在 iOS 应用程序中以某种方式编写如下代码?

Is it possible somehow to code like below in iOS app ?

if(app is live in app store)
{
   //Do something
}
else
{
  //Do other thing
}

我想避免我们的 QE/Dev 团队使用应用程序进行测试的情况.有没有一种方法可以检测应用程序代码的签名方式(开发人员/临时/分发)来检查?即使有可能,它也不会消除 Apple 使用我们的应用程序进行测试作为审查的一部分的情况.在我们的应用在 App Store 上线之前,我们记录了 Apple 对我们内容的多次下载.

I wanted to avoid cases where our QE/Dev team is using app for testing. Is there a way I can detect how app code is signed (Developer/Adhoc/Distribution) to check ? Even if it is possible, it will not eliminate cases when Apple is using our app for testing as part of review. We recorded many downloads of our content by Apple before our app goes live in App store.

推荐答案

您可以通过检查是否缺少 embedded.mobileprovision 来确定您的应用是否通过应用商店分发.此文件仅包含在临时构建中.

You can determine if your app was distributed via the app store by checking for the absence of embedded.mobileprovision. This file is only included in adhoc builds.

像这样:

if ([[NSBundle mainBundle] pathForResource:@"embedded"
                                    ofType:@"mobileprovision"]) {
  // not from app store (Apple's reviewers seem to hit this path)
} else {
  // from app store
}

这项技术来自 HockeyApp SDK.我个人在商店中有使用这种技术的应用程序,当然还有许多分发的应用程序包括 HockeyApp SDK.

This technique is from the HockeyApp SDK. I personally have applications in the store that use this technique, and of course there are many apps distributed that include the HockeyApp SDK.

基于我在来自应用商店"路径中的特定应用程序版本中意外发布的即时崩溃,Apple 团队将遵循不是来自应用商店"路径.让我的损失成为你的收获.:)

Based on an immediate crash I accidentally released in a particular build of my application in the "from app store" path, Apple's team will follow the "not from app store" path. Let my loss be your gain on that one. :)

884