diff --git a/Classes/BITAuthenticator.m b/Classes/BITAuthenticator.m index 68932a0c60..344d4ad062 100644 --- a/Classes/BITAuthenticator.m +++ b/Classes/BITAuthenticator.m @@ -67,8 +67,8 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44}; [self unregisterObservers]; } -- (instancetype) initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironment:(BOOL)isAppStoreEnvironment { - self = [super initWithAppIdentifier:appIdentifier isAppStoreEnvironment:isAppStoreEnvironment]; +- (instancetype)initWithAppIdentifier:(NSString *)appIdentifier isTestFlightEnvironment:(BOOL)isTestFlightEnvironment isAppStoreEnvironment:(BOOL)isAppStoreEnvironment { + self = [super initWithAppIdentifier:appIdentifier isTestFlightEnvironment:isTestFlightEnvironment isAppStoreEnvironment:isAppStoreEnvironment]; if( self ) { _webpageURL = [NSURL URLWithString:@"https://rink.hockeyapp.net/"]; @@ -82,8 +82,8 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44}; #pragma mark - BITHockeyBaseManager overrides - (void)startManager { - //disabled in the appStore - if([self isAppStoreEnvironment]) return; + //disabled in TestFlight and the AppStore + if([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) return; _isSetup = YES; } @@ -109,8 +109,8 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44}; } - (void)authenticateInstallation { - //disabled in the appStore - if([self isAppStoreEnvironment]) return; + //disabled in TestFlight and the AppStore + if([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) return; // make sure this is called after startManager so all modules are fully setup if (!_isSetup) { diff --git a/Classes/BITHockeyBaseManager.m b/Classes/BITHockeyBaseManager.m index d2dd74aa66..0ac749d518 100644 --- a/Classes/BITHockeyBaseManager.m +++ b/Classes/BITHockeyBaseManager.m @@ -51,8 +51,6 @@ UINavigationController *_navController; NSDateFormatter *_rfc3339Formatter; - - BOOL _isAppStoreEnvironment; } @@ -77,10 +75,11 @@ return self; } -- (instancetype)initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironment:(BOOL)isAppStoreEnvironment { +- (instancetype)initWithAppIdentifier:(NSString *)appIdentifier isTestFlightEnvironment:(BOOL)isTestFlightEnvironment isAppStoreEnvironment:(BOOL)isAppStoreEnvironment { if ((self = [self init])) { _appIdentifier = appIdentifier; - _isAppStoreEnvironment = isAppStoreEnvironment; + _testFlightEnvironment = isTestFlightEnvironment; + _appStoreEnvironment = isAppStoreEnvironment; } return self; } @@ -92,10 +91,6 @@ BITHockeyLog(@"ERROR: %@", [error localizedDescription]); } -- (BOOL)isAppStoreEnvironment { - return _isAppStoreEnvironment; -} - - (NSString *)encodedAppIdentifier { return bit_encodeAppIdentifier(_appIdentifier); } diff --git a/Classes/BITHockeyBaseManagerPrivate.h b/Classes/BITHockeyBaseManagerPrivate.h index 36828334ca..8ca80cf794 100644 --- a/Classes/BITHockeyBaseManagerPrivate.h +++ b/Classes/BITHockeyBaseManagerPrivate.h @@ -36,13 +36,14 @@ @property (nonatomic, strong) NSString *appIdentifier; -- (instancetype)initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironment:(BOOL)isAppStoreEnvironment; +@property (nonatomic, assign, readonly, getter=isTestFlightEnvironment) BOOL testFlightEnvironment; + +@property (nonatomic, assign, readonly, getter=isAppStoreEnvironment) BOOL appStoreEnvironment; + +- (instancetype)initWithAppIdentifier:(NSString *)appIdentifier isTestFlightEnvironment:(BOOL)isTestFlightEnvironment isAppStoreEnvironment:(BOOL)isAppStoreEnvironment; - (void)startManager; -/** the value this object was initialized with */ -- (BOOL)isAppStoreEnvironment; - /** Check if the device is running an iOS version previous to iOS 7 */ - (BOOL)isPreiOS7Environment; diff --git a/Classes/BITHockeyManager.m b/Classes/BITHockeyManager.m index 655c46fa01..915133f7f5 100644 --- a/Classes/BITHockeyManager.m +++ b/Classes/BITHockeyManager.m @@ -664,32 +664,32 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h if (_validAppIdentifier) { #if HOCKEYSDK_FEATURE_CRASH_REPORTER BITHockeyLog(@"INFO: Setup CrashManager"); - _crashManager = [[BITCrashManager alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironment:_appStoreEnvironment]; + _crashManager = [[BITCrashManager alloc] initWithAppIdentifier:_appIdentifier isTestFlightEnvironment:_testFlightEnvironment isAppStoreEnvironment:_appStoreEnvironment]; _crashManager.hockeyAppClient = [self hockeyAppClient]; _crashManager.delegate = _delegate; #endif /* HOCKEYSDK_FEATURE_CRASH_REPORTER */ #if HOCKEYSDK_FEATURE_UPDATES BITHockeyLog(@"INFO: Setup UpdateManager"); - _updateManager = [[BITUpdateManager alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironment:_appStoreEnvironment]; + _updateManager = [[BITUpdateManager alloc] initWithAppIdentifier:_appIdentifier isTestFlightEnvironment:_testFlightEnvironment isAppStoreEnvironment:_appStoreEnvironment]; _updateManager.delegate = _delegate; #endif /* HOCKEYSDK_FEATURE_UPDATES */ #if HOCKEYSDK_FEATURE_STORE_UPDATES BITHockeyLog(@"INFO: Setup StoreUpdateManager"); - _storeUpdateManager = [[BITStoreUpdateManager alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironment:_appStoreEnvironment]; + _storeUpdateManager = [[BITStoreUpdateManager alloc] initWithAppIdentifier:_appIdentifier isTestFlightEnvironment:_testFlightEnvironment isAppStoreEnvironment:_appStoreEnvironment]; _storeUpdateManager.delegate = _delegate; #endif /* HOCKEYSDK_FEATURE_STORE_UPDATES */ #if HOCKEYSDK_FEATURE_FEEDBACK BITHockeyLog(@"INFO: Setup FeedbackManager"); - _feedbackManager = [[BITFeedbackManager alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironment:_appStoreEnvironment]; + _feedbackManager = [[BITFeedbackManager alloc] initWithAppIdentifier:_appIdentifier isTestFlightEnvironment:_testFlightEnvironment isAppStoreEnvironment:_appStoreEnvironment]; _feedbackManager.delegate = _delegate; #endif /* HOCKEYSDK_FEATURE_FEEDBACK */ #if HOCKEYSDK_FEATURE_AUTHENTICATOR BITHockeyLog(@"INFO: Setup Authenticator"); - _authenticator = [[BITAuthenticator alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironment:_appStoreEnvironment]; + _authenticator = [[BITAuthenticator alloc] initWithAppIdentifier:_appIdentifier isTestFlightEnvironment:_testFlightEnvironment isAppStoreEnvironment:_appStoreEnvironment]; _authenticator.hockeyAppClient = [self hockeyAppClient]; _authenticator.delegate = _delegate; #endif /* HOCKEYSDK_FEATURE_AUTHENTICATOR */ diff --git a/Classes/BITUpdateManager.m b/Classes/BITUpdateManager.m index 249d214d27..e847c3e1f6 100644 --- a/Classes/BITUpdateManager.m +++ b/Classes/BITUpdateManager.m @@ -227,7 +227,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { #pragma mark - Expiry - (BOOL)expiryDateReached { - if ([self isAppStoreEnvironment]) return NO; + if ([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) return NO; if (_expiryDate) { NSDate *currentDate = [NSDate date]; @@ -314,7 +314,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { } - (void)stopUsage { - if ([self isAppStoreEnvironment]) return; + if ([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) return; if ([self expiryDateReached]) return; double timeDifference = [[NSDate date] timeIntervalSinceReferenceDate] - [_usageStartTimestamp timeIntervalSinceReferenceDate]; @@ -324,7 +324,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { } - (void) storeUsageTimeForCurrentVersion:(NSNumber *)usageTime { - if ([self isAppStoreEnvironment]) return; + if ([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) return; NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; @@ -518,7 +518,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { #pragma mark - BetaUpdateUI - (BITUpdateViewController *)hockeyViewController:(BOOL)modal { - if ([self isAppStoreEnvironment]) { + if ([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) { NSLog(@"[HockeySDK] This should not be called from an app store build!"); // return an empty view controller instead BITHockeyBaseViewController *blankViewController = [[BITHockeyBaseViewController alloc] initWithModalStyle:modal]; @@ -528,7 +528,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { } - (void)showUpdateView { - if ([self isAppStoreEnvironment]) { + if ([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) { NSLog(@"[HockeySDK] This should not be called from an app store build!"); return; } @@ -550,7 +550,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { - (void)showCheckForUpdateAlert { - if ([self isAppStoreEnvironment]) return; + if ([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) return; if ([self isUpdateManagerDisabled]) return; if (!_updateAlertShowing) { @@ -825,7 +825,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { } - (void)checkForUpdate { - if (![self isAppStoreEnvironment] && ![self isUpdateManagerDisabled]) { + if (![self isTestFlightEnvironment] && ![self isAppStoreEnvironment] && ![self isUpdateManagerDisabled]) { if ([self expiryDateReached]) return; if (![self installationIdentified]) return; @@ -838,7 +838,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { } - (void)checkForUpdateShowFeedback:(BOOL)feedback { - if ([self isAppStoreEnvironment]) return; + if ([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) return; if (self.isCheckInProgress) return; _showFeedback = feedback; @@ -916,7 +916,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { } - (BOOL)initiateAppDownload { - if ([self isAppStoreEnvironment]) return NO; + if ([self isTestFlightEnvironment] || [self isAppStoreEnvironment]) return NO; if (!self.isUpdateAvailable) { BITHockeyLog(@"WARNING: No update available. Aborting."); @@ -985,7 +985,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { // begin the startup process - (void)startManager { - if (![self isAppStoreEnvironment]) { + if (![self isTestFlightEnvironment] && ![self isAppStoreEnvironment]) { if ([self isUpdateManagerDisabled]) return; BITHockeyLog(@"INFO: Starting UpdateManager"); @@ -1040,7 +1040,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { self.companyName = (([[json valueForKey:@"company"] isKindOfClass:[NSString class]]) ? [json valueForKey:@"company"] : nil); - if (![self isAppStoreEnvironment]) { + if (![self isTestFlightEnvironment] && ![self isAppStoreEnvironment]) { NSArray *feedArray = (NSArray *)[json valueForKey:@"versions"]; // remember that we just checked the server diff --git a/Support/HockeySDKTests/BITAuthenticatorTests.m b/Support/HockeySDKTests/BITAuthenticatorTests.m index fd82d32eb0..ffaab70194 100644 --- a/Support/HockeySDKTests/BITAuthenticatorTests.m +++ b/Support/HockeySDKTests/BITAuthenticatorTests.m @@ -58,7 +58,7 @@ static void *kInstallationIdentification = &kInstallationIdentification; - (void)setUp { [super setUp]; - _sut = [[BITAuthenticator alloc] initWithAppIdentifier:nil isAppStoreEnvironment:NO]; + _sut = [[BITAuthenticator alloc] initWithAppIdentifier:nil isTestFlightEnvironment:NO isAppStoreEnvironment:NO]; } - (void)tearDown { @@ -87,7 +87,7 @@ static void *kInstallationIdentification = &kInstallationIdentification; #pragma mark - Persistence Tests - (void) testThatLastAuthenticatedVersionIsPersisted { _sut.lastAuthenticatedVersion = @"1.2.1"; - _sut = [[BITAuthenticator alloc] initWithAppIdentifier:nil isAppStoreEnvironment:YES]; + _sut = [[BITAuthenticator alloc] initWithAppIdentifier:nil isTestFlightEnvironment:NO isAppStoreEnvironment:YES]; assertThat(_sut.lastAuthenticatedVersion, equalTo(@"1.2.1")); } diff --git a/Support/HockeySDKTests/BITCrashManagerTests.m b/Support/HockeySDKTests/BITCrashManagerTests.m index dd028ed314..0cee4029e7 100644 --- a/Support/HockeySDKTests/BITCrashManagerTests.m +++ b/Support/HockeySDKTests/BITCrashManagerTests.m @@ -41,7 +41,7 @@ [super setUp]; _startManagerInitialized = NO; - _sut = [[BITCrashManager alloc] initWithAppIdentifier:nil isAppStoreEnvironment:NO]; + _sut = [[BITCrashManager alloc] initWithAppIdentifier:nil isTestFlightEnvironment:NO isAppStoreEnvironment:NO]; _hockeyAppClient = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString: BITHOCKEYSDK_URL]]; _hockeyAppClient.baseURL = [NSURL URLWithString:BITHOCKEYSDK_URL]; diff --git a/Support/HockeySDKTests/BITFeedbackManagerTests.m b/Support/HockeySDKTests/BITFeedbackManagerTests.m index a7b8bdf5af..93558ef063 100644 --- a/Support/HockeySDKTests/BITFeedbackManagerTests.m +++ b/Support/HockeySDKTests/BITFeedbackManagerTests.m @@ -36,7 +36,7 @@ BITHockeyManager *hm = [BITHockeyManager sharedHockeyManager]; hm.delegate = nil; - _sut = [[BITFeedbackManager alloc] initWithAppIdentifier:nil isAppStoreEnvironment:NO]; + _sut = [[BITFeedbackManager alloc] initWithAppIdentifier:nil isTestFlightEnvironment:NO isAppStoreEnvironment:NO]; _sut.delegate = nil; } diff --git a/Support/HockeySDKTests/BITStoreUpdateManagerTests.m b/Support/HockeySDKTests/BITStoreUpdateManagerTests.m index a57517dbb7..f89586cfb1 100644 --- a/Support/HockeySDKTests/BITStoreUpdateManagerTests.m +++ b/Support/HockeySDKTests/BITStoreUpdateManagerTests.m @@ -38,7 +38,7 @@ [super setUp]; // Set-up code here. - _storeUpdateManager = [[BITStoreUpdateManager alloc] initWithAppIdentifier:nil isAppStoreEnvironment:YES]; + _storeUpdateManager = [[BITStoreUpdateManager alloc] initWithAppIdentifier:nil isTestFlightEnvironment:NO isAppStoreEnvironment:YES]; } - (void)tearDown {