简体   繁体   English

如何检测是从应用商店还是从MDM商店安装了应用?

[英]How to detect if app was installed from the app store or from MDM store?

The application can be installed from Appstore, and also via Enterprise distribution. 该应用程序可以从Appstore安装,也可以通过企业发行版安装。 What I basically want to implement is, if app was downloaded from appstore, I will enable/disable some features. 我基本上想要实现的是,如果从appstore下载了app,我将启用/禁用某些功能。 Else if, app was installed from say, MobileIRON's appstore, which as a MDM vendor, I will enable/disable some features. 否则,如果应用是从MobileIRON的应用商店(作为MDM供应商)安装的,则我将启用/禁用某些功能。 The application binary that will be uploaded to both the store will be same. 将要上传到两个商店的应用程序二进制文件将是相同的。 So how can I programmatically differ if Application was installed from Appstore or from the MDM store? 那么,如果从Appstore或MDM存储中安装了Application,我在程序上有何不同?

Have checked many related questions, but none actually answers this case correctly. 已经检查了许多相关问题,但是没有一个人能正确回答这种情况。 Does reading for the embedded.mobileprovision file from the application bundle will be enough or is there any other way to detect the source of installation. 从应用程序捆绑中读取Embedded.mobileprovision文件是否足够或者是否有其他方法可以检测安装源。

EDIT : Based upon the reply, is there anyway I can place some value somewhere during build, so that later I can extract that value based on the source of installation ? 编辑:根据答复,无论如何我在构建过程中是否可以放置一些值,以便以后可以根据安装源提取该值? Will be very much grateful if anyone can provide some ideas. 如果有人可以提供一些想法,将不胜感激。

Instead of trying to determine which "store" you are trying to target, Create a new target for your App (you can name this "My App Enterprise" for example). 无需尝试确定要定位的“商店”,而是为您的应用创建一个新的目标(例如,您可以将其命名为“ My App Enterprise”)。

在此处输入图片说明

Then, create an entry in your Build Settings -> Other C Flags : 然后,在构建设置 -> 其他C标志中创建一个条目:

-DTARGET_ENTERPRISE=1 // the Flag "-D" precedes "TARGET_ENTERPRISE", 1 = TRUE -DTARGET_ENTERPRISE = 1 //标志“ -D”在“ TARGET_ENTERPRISE”之前,1 = TRUE

In your code 在你的代码中

- (void)someRoutine
{
#ifdef TARGET_ENTERPRISE
    // Do something or show something specifically for Enterprise apps
#else
    // Do something or show something specifically for App Store apps
#endif
}

Note that this will require you to provide 2 builds (AdHoc/Release and Enterprise). 请注意,这将需要您提供2个内部版本(AdHoc / Release和Enterprise)。

Apple has introduced with iOS 7 the so called "Managed App Configuration". 苹果公司在iOS 7中引入了所谓的“托管应用程序配置”。

https://developer.apple.com/library/ios/samplecode/sc2279/Introduction/Intro.html https://developer.apple.com/library/ios/samplecode/sc2279/Introduction/Intro.html

This allows a MDM system to deploy NSDictionary values via MDM into a reserved namespace in NSUserDefaults. 这允许MDM系统通过MDM将NSDictionary值部署到NSUserDefaults中的保留名称空间中。 If your app finds a value in there/can access the namespace you're in MDM. 如果您的应用在其中找到值/可以访问您在MDM中的名称空间。

We're using that for our App Store apps since then. 从那时起,我们就将其用于App Store应用程序。 No need to have two binaries. 不需要两个二进制文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果未从应用商店安装,如何更新 Xcode - How to update Xcode if not installed from app store 如何检测当前运行的应用是否是从应用商店安装的? - How can I detect if the currently running app was installed from the app store? 如果未安装应用程序,如何从深层链接重定向到应用程序商店? - How to redirect to the app store from a deep link if the app is not installed? 检测移动应用程序是从 AppStore/Play Store 中的 Production Track 还是 Beta Track 安装的 - Detect if mobile app was installed from Production Track or Beta Track in AppStore/Play Store 仅当从应用商店安装时,iOS应用才会崩溃 - IOS app crashing only if installed from app store iOS - 从 App Store 安装旧版本的应用程序 - iOS - old versions of app getting installed from the App Store iPhoneX 错误 - 此应用不是从 App Store 安装的,必须手动重新安装 - iPhoneX Error - This app was not installed from the App Store and must be reinstalled manually 来自 App Store 的 Xcode 11 说无法安装应用程序 - Xcode 11 from App Store says app can't be installed iOS-从应用商店中安装的旧应用版本 - IOS - Old app version being installed from the app store 应用程序崩溃-从应用程序商店而非本地安装时 - App crash - when installed from App store but not locally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM