mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-31 07:30:40 +00:00
Fail if the developer tries to setup the SDK on a background thread
Fixes #39
This commit is contained in:
parent
b6c77b8fb3
commit
857bd24f6e
@ -54,7 +54,9 @@
|
||||
`BITCrashManager`: Shows an alert on startup asking the user if he/she agrees on sending the crash report, if `[BITCrashManager crashManagerStatus]` is set to `BITCrashManagerStatusAlwaysAsk` (default)
|
||||
`BITUpdateManager`: Is automatically deactivated when the SDK detects it is running from a build distributed via the App Store. Otherwise if it is not deactivated manually, it will show an alert after startup informing the user about a pending update, if one is available. If the user then decides to view the update another screen is presented with further details and an option to install the update.
|
||||
`BITFeedbackManager`: If this module is deactivated or the user interface is nowhere added into the app, this module will not do anything. It will not fetch the server for data or show any user interface. If it is integrated, activated, and the user already used it to provide feedback, it will show an alert after startup if a new answer has been received from the server with the option to view it.
|
||||
|
||||
|
||||
@warning The SDK is **NOT** thread safe and has to be set up on the main thread!
|
||||
|
||||
@warning You should **NOT** change any module configuration after calling `startManager`!
|
||||
|
||||
Example:
|
||||
|
@ -150,6 +150,8 @@
|
||||
- (void)startManager {
|
||||
if (!_validAppIdentifier) return;
|
||||
|
||||
if (![self isSetUpOnMainThread]) return;
|
||||
|
||||
BITHockeyLog(@"INFO: Starting HockeyManager");
|
||||
_startManagerIsInvoked = YES;
|
||||
|
||||
@ -225,6 +227,22 @@
|
||||
|
||||
#pragma mark - Private Instance Methods
|
||||
|
||||
- (BOOL)isSetUpOnMainThread {
|
||||
NSString *errorString = @"ERROR: This SDK has to be setup on the main thread!";
|
||||
|
||||
if (!NSThread.isMainThread) {
|
||||
if (self.isAppStoreEnvironment) {
|
||||
BITHockeyLog(@"%@", errorString);
|
||||
} else {
|
||||
NSAssert(NSThread.isMainThread, errorString);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)shouldUseLiveIdentifier {
|
||||
BOOL delegateResult = NO;
|
||||
if ([_delegate respondsToSelector:@selector(shouldUseLiveIdentifierForHockeyManager:)]) {
|
||||
@ -237,6 +255,8 @@
|
||||
- (void)initializeModules {
|
||||
_validAppIdentifier = [self checkValidityOfAppIdentifier:_appIdentifier];
|
||||
|
||||
if (![self isSetUpOnMainThread]) return;
|
||||
|
||||
_startManagerIsInvoked = NO;
|
||||
|
||||
if (_validAppIdentifier) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user