Search code examples
iosobjective-capp-storemdm

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.


Solution

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