2

The application can be installed from Appstore, and also via Enterprise distribution. What I basically want to implement is, if app was downloaded from appstore, I will enable/disable some features. Else if, app was installed from say, MobileIRON's appstore, which as a MDM vendor, I will enable/disable some features. 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?

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.

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.

Shane D
  • 834
  • 9
  • 23
  • "The application binary that will be uploaded to both the store will be same." I think there's no way to detect without upload two different binaries – zy.liu Aug 17 '15 at 16:56
  • As replied I'd use Managed App configuration. Starting with iOS9 companies can change the status of a "manually App Store Installed App" to a "managed App Store Installed App". Basically an auto-conversion between your two types... – muenzpraeger Jul 16 '16 at 21:53
  • Linking this answer to http://stackoverflow.com/questions/20752254/using-mdm-to-configure-an-enterprise-app-via-nsuserdefaults which also has a ton of relevant information on this topic – glenc Apr 02 '17 at 18:13

2 Answers2

2

Apple has introduced with iOS 7 the so called "Managed App Configuration".

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. If your app finds a value in there/can access the namespace you're in MDM.

We're using that for our App Store apps since then. No need to have two binaries.

muenzpraeger
  • 373
  • 1
  • 5
  • Well, this is an option, but what if you install managed app, but will not push configuration in it and use default values? – Balki Apr 28 '16 at 09:04
  • You've to set the default values in your app as you'd would do with any other values. And then pick - in case of existence - the MDM values to override them. – muenzpraeger Jul 16 '16 at 21:50
  • Yes, default values are correct to be uses, but then this doesn't solve the original question, how you will know that app was installed from MDM if you use default values from your app. – Balki Feb 02 '17 at 15:53
  • It solves the original question. Just add an additional default like "isMDMInstalled" that you only provision via MDM and not as a default value in the app. – muenzpraeger Feb 03 '17 at 06:24
  • 1
    Sure, that way you will know, but you have to push configuration to the app from MDM portal. If you just install app you will not know whether it was installed using MDM. And if your app is used by your customers your would need to force all of them to push this setting, which is not the best solution. – Balki Feb 17 '17 at 17:04
  • Sorry, balki, but you don't understand how Apple MDM works. – muenzpraeger Feb 19 '17 at 23:53
  • Hi muenzpraeger, by dishonesting your oponents you will not help others to solve this issue! And are you saying that there can be configured some default settings that are pushed to NSUserDefaults without need to configure them at MDM portal? I know I can programatically add some defaults and I have it that way, but I don't see option to have them set one way when app is installed from AppStore and other way when app is installed from MDM portal without need to configure those settings manually in the portal. – Balki Feb 21 '17 at 09:30
1

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).

enter image description here

Then, create an entry in your Build Settings -> Other C Flags:

-DTARGET_ENTERPRISE=1 // the Flag "-D" precedes "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).

WrightsCS
  • 50,551
  • 22
  • 134
  • 186