mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-19 02:36:29 +00:00
Move client reconfiguration on serverURL change into BITCrashManager
Having the different logics for retrieving an instance of `BITHockeyAppClient` on `BITHockeyManager` felt strange, therefore I decided to move the logic necessary when the serverURL of the `BITCrashManager` instance changes into the manager itself.
This commit is contained in:
@@ -200,12 +200,15 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
id _networkDidBecomeReachableObserver;
|
||||
}
|
||||
|
||||
@synthesize serverURL = _serverURL;
|
||||
|
||||
- (instancetype)init {
|
||||
if ((self = [super init])) {
|
||||
- (instancetype)initWithAppIdentifier:(NSString *)appIdentifier appEnvironment:(BITEnvironment)environment hockeyAppClient:(BITHockeyAppClient *)hockeyAppClient {
|
||||
if ((self = [super initWithAppIdentifier:appIdentifier appEnvironment:environment])) {
|
||||
_delegate = nil;
|
||||
_isSetup = NO;
|
||||
|
||||
_hockeyAppClient = hockeyAppClient;
|
||||
|
||||
_showAlwaysButton = YES;
|
||||
_alertViewHandler = nil;
|
||||
|
||||
@@ -264,6 +267,12 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:crashManagerStatus forKey:kBITCrashManagerStatus];
|
||||
}
|
||||
|
||||
- (void)setServerURL:(NSString *)serverURL {
|
||||
if ([serverURL isEqualToString:_serverURL]) { return; }
|
||||
|
||||
_serverURL = serverURL;
|
||||
self.hockeyAppClient = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString:serverURL]];
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@
|
||||
|
||||
#endif /* HOCKEYSDK_FEATURE_AUTHENTICATOR */
|
||||
|
||||
- (instancetype)initWithAppIdentifier:(NSString *)appIdentifier appEnvironment:(BITEnvironment)environment hockeyAppClient:(BITHockeyAppClient *)hockeyAppClient NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (void)cleanCrashReports;
|
||||
|
||||
- (NSString *)userIDForCrashReport;
|
||||
|
||||
@@ -241,7 +241,6 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
|
||||
// start CrashManager
|
||||
if (![self isCrashManagerDisabled]) {
|
||||
BITHockeyLogDebug(@"INFO: Start CrashManager");
|
||||
[_crashManager setHockeyAppClient:[self hockeyAppClientWithServerURL:_crashManager.serverURL]];
|
||||
|
||||
#if HOCKEYSDK_FEATURE_AUTHENTICATOR
|
||||
if (_authenticator) {
|
||||
@@ -539,13 +538,6 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
|
||||
return _hockeyAppClient;
|
||||
}
|
||||
|
||||
- (BITHockeyAppClient *)hockeyAppClientWithServerURL:(NSString *)serverURL {
|
||||
if (!serverURL || [serverURL isEqualToString:self.serverURL]) {
|
||||
return [self hockeyAppClient];
|
||||
}
|
||||
return [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString:serverURL]];
|
||||
}
|
||||
|
||||
- (NSString *)integrationFlowTimeString {
|
||||
NSString *timeString = [[NSBundle mainBundle] objectForInfoDictionaryKey:BITHOCKEY_INTEGRATIONFLOW_TIMESTAMP];
|
||||
|
||||
@@ -693,7 +685,9 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
|
||||
if (_validAppIdentifier) {
|
||||
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
|
||||
BITHockeyLogDebug(@"INFO: Setup CrashManager");
|
||||
_crashManager = [[BITCrashManager alloc] initWithAppIdentifier:_appIdentifier appEnvironment:_appEnvironment];
|
||||
_crashManager = [[BITCrashManager alloc] initWithAppIdentifier:_appIdentifier
|
||||
appEnvironment:_appEnvironment
|
||||
hockeyAppClient:[self hockeyAppClient]];
|
||||
_crashManager.delegate = _delegate;
|
||||
#endif /* HOCKEYSDK_FEATURE_CRASH_REPORTER */
|
||||
|
||||
|
||||
@@ -40,12 +40,7 @@ static NSString *const kBITCrashMetaAttachment = @"BITCrashMetaAttachment";
|
||||
[super setUp];
|
||||
|
||||
_startManagerInitialized = NO;
|
||||
_sut = [[BITCrashManager alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentOther];
|
||||
|
||||
_hockeyAppClient = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString: BITHOCKEYSDK_URL]];
|
||||
_hockeyAppClient.baseURL = [NSURL URLWithString:BITHOCKEYSDK_URL];
|
||||
|
||||
[_sut setHockeyAppClient:_hockeyAppClient];
|
||||
_sut = [[BITCrashManager alloc] initWithAppIdentifier:nil appEnvironment:BITEnvironmentOther hockeyAppClient:[[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString: BITHOCKEYSDK_URL]]];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
|
||||
Reference in New Issue
Block a user