2

My application can be installed from Appstore, and also via Enterprise distribution.
The code is completely same.
So how can I programmatically differ if Application was installed from Appstore?

l0gg3r
  • 8,864
  • 3
  • 26
  • 46
Yucel Bayram
  • 1,653
  • 2
  • 22
  • 41

2 Answers2

6

You can get part of the way there by reading in the embedded.mobileprovision file from the application bundle:

NSString *provisionPath = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
if (![[NSFileManager defaultManager] fileExistsAtPath:provisionPath]) {
    // Appstore version
}

If that does not exist, you are in an app store build.

If it does exist, you need to figure out some difference between your debug and ad-hoc provisioning profiles, and look for that to determine which build you are in.

Regarding to /private/var/mobile/Containers/Bundle/Application/
This is a safe way, you can check [[NSBundle mainBundle] resourcePath],
that's the path from where images and resources are loaded,
it starts with /private/var/mobile/Containers/Bundle/Application/...

So reading/checking your bundle files, will not cause rejection.

l0gg3r
  • 8,864
  • 3
  • 26
  • 46
  • Hmm thanks it looks useful. It returned something like that. provisionPath=/private/var/mobile/Containers/Bundle/Application/FCxxxxxxxSomeNumbers/MyOwnApp.app/embedded.mobileprovision. If it is app store build then provisionPath will return nil? or it will still return until /MyOwnApp.app/ ? – Yucel Bayram Nov 20 '14 at 11:24
  • May I make a small point, notice the word `private` in the path. You shouldn't really be accessing things in the private folder at all and this will probably get your app rejected – Popeye Nov 20 '14 at 11:36
  • @Popeye, your Application bundle is there, so you can't access your bundle? – l0gg3r Nov 20 '14 at 11:48
  • 1
    @yucelbayram you need to check using `[[NSFileManager defaultManager] fileExistsAtPath:provisionPath];` – l0gg3r Nov 20 '14 at 11:50
  • @Popeye Yes thanks for the help. I did not notice that. – Yucel Bayram Nov 20 '14 at 12:04
  • @yucelbayram `I0gg3r` is right it is your own bundle so it shouldn't really make to much of a difference but if a folder is called private I always edge on the side of caution, because we all know what Apple is like, but on an App store released app it wouldn't return anything anyway. – Popeye Nov 20 '14 at 12:10
  • @Popeye Yes This app already on appstore. I m trying to make new version. But you are right about private. I am trying to change this private stuff. – Yucel Bayram Nov 20 '14 at 12:12
  • 1
    @yucelbayram you will not get rejected 100% , – l0gg3r Nov 20 '14 at 12:24
  • Answer partially plagiarises https://stackoverflow.com/a/16089150 Would have been nice to give credit where due. – batman Apr 13 '22 at 06:51
0

No you can not identify that. If you have shared the credentials to anyone else and if he has downloaded the app using it, there is no way for you to check the same.

Apurv
  • 17,116
  • 8
  • 51
  • 67