mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Add support for SDK integration workflow
This commit is contained in:
parent
8cf4665570
commit
117265f15c
@ -33,6 +33,7 @@
|
|||||||
#import "BITHockeyBaseManagerPrivate.h"
|
#import "BITHockeyBaseManagerPrivate.h"
|
||||||
|
|
||||||
#import "BITHockeyHelper.h"
|
#import "BITHockeyHelper.h"
|
||||||
|
#import "BITHockeyAppClient.h"
|
||||||
|
|
||||||
|
|
||||||
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
|
#if HOCKEYSDK_FEATURE_CRASH_REPORTER
|
||||||
@ -53,7 +54,6 @@
|
|||||||
|
|
||||||
#if HOCKEYSDK_FEATURE_AUTHENTICATOR
|
#if HOCKEYSDK_FEATURE_AUTHENTICATOR
|
||||||
#import "BITAuthenticator_Private.h"
|
#import "BITAuthenticator_Private.h"
|
||||||
#import "BITHockeyAppClient.h"
|
|
||||||
#endif /* HOCKEYSDK_FEATURE_AUTHENTICATOR */
|
#endif /* HOCKEYSDK_FEATURE_AUTHENTICATOR */
|
||||||
|
|
||||||
@interface BITHockeyManager ()
|
@interface BITHockeyManager ()
|
||||||
@ -75,6 +75,8 @@
|
|||||||
BOOL _startManagerIsInvoked;
|
BOOL _startManagerIsInvoked;
|
||||||
|
|
||||||
BOOL _startUpdateManagerIsInvoked;
|
BOOL _startUpdateManagerIsInvoked;
|
||||||
|
|
||||||
|
BITHockeyAppClient *_hockeyAppClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Private Class Methods
|
#pragma mark - Private Class Methods
|
||||||
@ -121,6 +123,8 @@
|
|||||||
_serverURL = nil;
|
_serverURL = nil;
|
||||||
_delegate = nil;
|
_delegate = nil;
|
||||||
|
|
||||||
|
_hockeyAppClient = nil;
|
||||||
|
|
||||||
_disableCrashManager = NO;
|
_disableCrashManager = NO;
|
||||||
_disableUpdateManager = NO;
|
_disableUpdateManager = NO;
|
||||||
_disableFeedbackManager = NO;
|
_disableFeedbackManager = NO;
|
||||||
@ -305,9 +309,10 @@
|
|||||||
|
|
||||||
if (_serverURL != aServerURL) {
|
if (_serverURL != aServerURL) {
|
||||||
_serverURL = [aServerURL copy];
|
_serverURL = [aServerURL copy];
|
||||||
#if HOCKEYSDK_FEATURE_AUTHENTICATOR
|
|
||||||
_authenticator.hockeyAppClient.baseURL = [NSURL URLWithString:_serverURL ? _serverURL : BITHOCKEYSDK_URL];
|
if (_hockeyAppClient) {
|
||||||
#endif /* HOCKEYSDK_FEATURE_AUTHENTICATOR */
|
_hockeyAppClient.baseURL = [NSURL URLWithString:_serverURL ? _serverURL : BITHOCKEYSDK_URL];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,6 +380,69 @@
|
|||||||
|
|
||||||
#pragma mark - Private Instance Methods
|
#pragma mark - Private Instance Methods
|
||||||
|
|
||||||
|
- (BITHockeyAppClient *)hockeyAppClient {
|
||||||
|
if (!_hockeyAppClient) {
|
||||||
|
_hockeyAppClient = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString:_serverURL ? _serverURL : BITHOCKEYSDK_URL]];
|
||||||
|
|
||||||
|
_hockeyAppClient.baseURL = [NSURL URLWithString:_serverURL ? _serverURL : BITHOCKEYSDK_URL];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _hockeyAppClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)integrationFlowTimeString {
|
||||||
|
NSString *timeString = [[NSBundle mainBundle] objectForInfoDictionaryKey:BITHOCKEY_INTEGRATIONFLOW_TIMESTAMP];
|
||||||
|
|
||||||
|
return timeString;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)integrationFlowStartedWithTimeString:(NSString *)timeString {
|
||||||
|
if (timeString == nil || [self isAppStoreEnvironment]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||||
|
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
|
||||||
|
[dateFormatter setLocale:enUSPOSIXLocale];
|
||||||
|
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
|
||||||
|
NSDate *integrationFlowStartDate = [dateFormatter dateFromString:timeString];
|
||||||
|
|
||||||
|
if (integrationFlowStartDate && [integrationFlowStartDate timeIntervalSince1970] > [[NSDate date] timeIntervalSince1970] - (60 * 10) ) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)pingServerForIntegrationStartWorkflowWithTimeString:(NSString *)timeString {
|
||||||
|
if (!_appIdentifier || [self isAppStoreEnvironment]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *integrationPath = [NSString stringWithFormat:@"api/3/apps/%@/integration", bit_encodeAppIdentifier(_appIdentifier)];
|
||||||
|
|
||||||
|
BITHockeyLog(@"INFO: Sending integration workflow ping to %@", integrationPath);
|
||||||
|
|
||||||
|
[[self hockeyAppClient] postPath:integrationPath
|
||||||
|
parameters:@{@"timestamp": timeString}
|
||||||
|
completion:^(BITHTTPOperation *operation, NSData* responseData, NSError *error) {
|
||||||
|
switch (operation.response.statusCode) {
|
||||||
|
case 400:
|
||||||
|
BITHockeyLog(@"ERROR: App ID not found");
|
||||||
|
break;
|
||||||
|
case 201:
|
||||||
|
BITHockeyLog(@"INFO: Ping accepted.");
|
||||||
|
break;
|
||||||
|
case 200:
|
||||||
|
BITHockeyLog(@"INFO: Ping accepted. Server already knows.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BITHockeyLog(@"ERROR: Unknown error");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)validateStartManagerIsInvoked {
|
- (void)validateStartManagerIsInvoked {
|
||||||
if (_validAppIdentifier && !_appStoreEnvironment) {
|
if (_validAppIdentifier && !_appStoreEnvironment) {
|
||||||
if (!_startManagerIsInvoked) {
|
if (!_startManagerIsInvoked) {
|
||||||
@ -461,9 +529,8 @@
|
|||||||
|
|
||||||
#if HOCKEYSDK_FEATURE_AUTHENTICATOR
|
#if HOCKEYSDK_FEATURE_AUTHENTICATOR
|
||||||
BITHockeyLog(@"INFO: Setup Authenticator");
|
BITHockeyLog(@"INFO: Setup Authenticator");
|
||||||
BITHockeyAppClient *client = [[BITHockeyAppClient alloc] initWithBaseURL:[NSURL URLWithString:_serverURL ? _serverURL : BITHOCKEYSDK_URL]];
|
|
||||||
_authenticator = [[BITAuthenticator alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironment:_appStoreEnvironment];
|
_authenticator = [[BITAuthenticator alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironment:_appStoreEnvironment];
|
||||||
_authenticator.hockeyAppClient = client;
|
_authenticator.hockeyAppClient = [self hockeyAppClient];
|
||||||
_authenticator.delegate = _delegate;
|
_authenticator.delegate = _delegate;
|
||||||
#endif /* HOCKEYSDK_FEATURE_AUTHENTICATOR */
|
#endif /* HOCKEYSDK_FEATURE_AUTHENTICATOR */
|
||||||
|
|
||||||
@ -482,6 +549,12 @@
|
|||||||
|
|
||||||
#endif /* HOCKEYSDK_FEATURE_UPDATES */
|
#endif /* HOCKEYSDK_FEATURE_UPDATES */
|
||||||
|
|
||||||
|
if (![self isAppStoreEnvironment]) {
|
||||||
|
NSString *integrationFlowTime = [self integrationFlowTimeString];
|
||||||
|
if (integrationFlowTime && [self integrationFlowStartedWithTimeString:integrationFlowTime]) {
|
||||||
|
[self pingServerForIntegrationStartWorkflowWithTimeString:integrationFlowTime];
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
[self logInvalidIdentifier:@"app identifier"];
|
[self logInvalidIdentifier:@"app identifier"];
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,8 @@
|
|||||||
#define kBITStoreUpdateLastUUID @"BITStoreUpdateLastUUID"
|
#define kBITStoreUpdateLastUUID @"BITStoreUpdateLastUUID"
|
||||||
#define kBITStoreUpdateIgnoreVersion @"BITStoreUpdateIgnoredVersion"
|
#define kBITStoreUpdateIgnoreVersion @"BITStoreUpdateIgnoredVersion"
|
||||||
|
|
||||||
|
#define BITHOCKEY_INTEGRATIONFLOW_TIMESTAMP @"BITIntegrationFlowStartTimestamp"
|
||||||
|
|
||||||
#define BITHOCKEYSDK_BUNDLE @"HockeySDKResources.bundle"
|
#define BITHOCKEYSDK_BUNDLE @"HockeySDKResources.bundle"
|
||||||
#define BITHOCKEYSDK_URL @"https://sdk.hockeyapp.net/"
|
#define BITHOCKEYSDK_URL @"https://sdk.hockeyapp.net/"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user