Move AppStore detection and adapt for TestFlight

This commit is contained in:
Lukas Spieß
2015-10-01 13:35:17 +02:00
parent 44b231225c
commit 13aaaa6ae0
3 changed files with 57 additions and 1 deletions

View File

@@ -47,6 +47,10 @@ NSString *bit_UUID(void);
NSString *bit_appAnonID(BOOL forceNewAnonID);
BOOL bit_isPreiOS7Environment(void);
BOOL bit_isPreiOS8Environment(void);
BOOL bit_isAppStoreReceiptSandbox(void);
BOOL bit_hasEmbeddedMobileProvision(void);
BOOL bit_isRunningInTestFlightEnvironment(void);
BOOL bit_isRunningInAppStoreEnvironment(void);
BOOL bit_isRunningInAppExtension(void);
#if !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnly) && !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnlyExtensions)

View File

@@ -271,6 +271,45 @@ BOOL bit_isPreiOS8Environment(void) {
return isPreiOS8Environment;
}
BOOL bit_isAppStoreReceiptSandbox(void) {
#if TARGET_IPHONE_SIMULATOR
return NO;
#else
NSURL *appStoreReceiptURL = NSBundle.mainBundle.appStoreReceiptURL;
NSString *appStoreReceiptLastComponent = appStoreReceiptURL.lastPathComponent;
BOOL isSandboxReceipt = [appStoreReceiptLastComponent isEqualToString:@"sandboxReceipt"];
return isSandboxReceipt;
#endif
}
BOOL bit_hasEmbeddedMobileProvision(void) {
BOOL hasEmbeddedMobileProvision = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
return hasEmbeddedMobileProvision;
}
BOOL bit_isRunningInTestFlightEnvironment(void) {
#if TARGET_IPHONE_SIMULATOR
return NO;
#else
if (bit_isAppStoreReceiptSandbox() && !bit_hasEmbeddedMobileProvision()) {
return YES;
}
return NO;
#endif
}
BOOL bit_isRunningInAppStoreEnvironment(void) {
#if TARGET_IPHONE_SIMULATOR
return NO;
#else
if (bit_isAppStoreReceiptSandbox() || bit_hasEmbeddedMobileProvision()) {
return NO;
}
return YES;
#endif
}
BOOL bit_isRunningInAppExtension(void) {
static BOOL isRunningInAppExtension = NO;
static dispatch_once_t checkAppExtension;

View File

@@ -75,6 +75,15 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
@interface BITHockeyManager ()
/**
Flag that determines whether the application is installed and running
from an App Store installation.
Returns _YES_ if the app is installed and running from the App Store
Returns _NO_ if the app is installed via debug, ad-hoc or enterprise distribution
*/
@property (nonatomic, readonly, getter=isTestFlightEnvironment) BOOL testFlightEnvironment;
- (BOOL)shouldUseLiveIdentifier;
@end
@@ -156,6 +165,7 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
_enableStoreUpdateManager = NO;
#endif
_testFlightEnvironment = NO;
_appStoreEnvironment = NO;
_startManagerIsInvoked = NO;
_startUpdateManagerIsInvoked = NO;
@@ -166,9 +176,12 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
#if !TARGET_IPHONE_SIMULATOR
// check if we are really in an app store environment
if (![[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
if (bit_isRunningInAppStoreEnvironment()) {
_appStoreEnvironment = YES;
}
if (bit_isRunningInTestFlightEnvironment()) {
_testFlightEnvironment = YES;
}
#endif
[self performSelector:@selector(validateStartManagerIsInvoked) withObject:nil afterDelay:0.0f];