Shane D
Shane D

Reputation: 884

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

Upvotes: 3

Views: 2916

Answers (2)

muenzpraeger
muenzpraeger

Reputation: 373

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.

Upvotes: 2

WrightsCS
WrightsCS

Reputation: 50717

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

Upvotes: 1

Related Questions