Detect AppStore installation of iOS app

喜欢而已 提交于 2019-12-03 07:57:13

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

Because XCode automatically sets up applications with a "DEBUG" flag in the Debug config, that is not set in Release (which is used by default for AdHoc builds), you may be better off disabling logging in an app store build and determining the level of logging based on the DEBUG macro flag.

You could use build configurations that define a macro to let you know that you've built for testflight.

For example, we have debug builds set a macro USE_TESTFLIGHT, and in our code we do:

#ifdef USE_TESTFLIGHT
//do something test-flight specific
[TestFlight takeOff:kTestFlightAppToken];
#endif

You could create new build configs that setup different macros depending on how you are compiling/distributing the app, and use ifdef's to perform different tasks based on those.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!