[英]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
- (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.