Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #129 from bitstadium/fix/cleanup-nsurlsession
Browse files Browse the repository at this point in the history
Fix/cleanup nsurlsession
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Sep 20, 2017
2 parents c4a1a17 + c7fa787 commit 88220e6
Show file tree
Hide file tree
Showing 24 changed files with 416 additions and 695 deletions.
2 changes: 1 addition & 1 deletion Classes/BITHockeyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
* Please be aware that the URL for `BITMetricsManager` needs to be set separately
* as this class uses a different endpoint!
*/
@property (nonatomic, strong) NSString *serverURL;
@property (nonatomic, copy) NSString *serverURL;

/**
* Reference to the initialized BITCrashManager module
Expand Down
59 changes: 36 additions & 23 deletions Classes/BITHockeyManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,44 @@ - (void)pingServerForIntegrationStartWorkflowWithTimeString:(NSString *)timeStri
}

NSString *integrationPath = [NSString stringWithFormat:@"api/3/apps/%@/integration", [self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

BITHockeyLogDebug(@"INFO: Sending integration workflow ping to %@", integrationPath);

[[self hockeyAppClient] postPath:integrationPath
parameters:@{@"timestamp": timeString,
@"sdk": BITHOCKEY_NAME,
@"sdk_version": BITHOCKEY_VERSION,
@"bundle_version": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
}
completion:^(BITHTTPOperation *operation, NSData * __unused responseData, NSError * __unused error) {
switch (operation.response.statusCode) {
case 400:
BITHockeyLogError(@"ERROR: App ID not found");
break;
case 201:
BITHockeyLogDebug(@"INFO: Ping accepted.");
break;
case 200:
BITHockeyLogDebug(@"INFO: Ping accepted. Server already knows.");
break;
default:
BITHockeyLogError(@"ERROR: Unknown error");
break;
}
}];
NSDictionary *params = @{@"timestamp": timeString,
@"sdk": BITHOCKEY_NAME,
@"sdk_version": BITHOCKEY_VERSION,
@"bundle_version": (id)[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
};

NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
__block NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];
NSURLRequest *request = [[self hockeyAppClient] requestWithMethod:@"POST" path:integrationPath parameters:params];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
completionHandler: ^(NSData * __unused data, NSURLResponse *response, NSError * __unused error) {
[session finishTasksAndInvalidate];

NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*) response;
[self logPingMessageForStatusCode:httpResponse.statusCode];
}];
[task resume];

}

- (void)logPingMessageForStatusCode:(NSInteger)statusCode {
switch (statusCode) {
case 400:
BITHockeyLogError(@"ERROR: App ID not found");
break;
case 201:
BITHockeyLogDebug(@"INFO: Ping accepted.");
break;
case 200:
BITHockeyLogDebug(@"INFO: Ping accepted. Server already knows.");
break;
default:
BITHockeyLogError(@"ERROR: Unknown error");
break;
}
}


Expand Down
22 changes: 11 additions & 11 deletions Classes/CrashReporting/BITCrashDetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,62 @@
/**
* UUID for the crash report
*/
@property (nonatomic, readonly, strong) NSString *incidentIdentifier;
@property (nonatomic, readonly, copy) NSString *incidentIdentifier;

/**
* UUID for the app installation on the device
*/
@property (nonatomic, readonly, strong) NSString *reporterKey;
@property (nonatomic, readonly, copy) NSString *reporterKey;

/**
* Signal that caused the crash
*/
@property (nonatomic, readonly, strong) NSString *signal;
@property (nonatomic, readonly, copy) NSString *signal;

/**
* Exception name that triggered the crash, nil if the crash was not caused by an exception
*/
@property (nonatomic, readonly, strong) NSString *exceptionName;
@property (nonatomic, readonly, copy) NSString *exceptionName;

/**
* Exception reason, nil if the crash was not caused by an exception
*/
@property (nonatomic, readonly, strong) NSString *exceptionReason;
@property (nonatomic, readonly, copy) NSString *exceptionReason;

/**
* Date and time the app started, nil if unknown
*/
@property (nonatomic, readonly, strong) NSDate *appStartTime;
@property (nonatomic, readonly, copy) NSDate *appStartTime;

/**
* Date and time the crash occured, nil if unknown
*/
@property (nonatomic, readonly, strong) NSDate *crashTime;
@property (nonatomic, readonly, copy) NSDate *crashTime;

/**
* Operation System version string the app was running on when it crashed.
*/
@property (nonatomic, readonly, strong) NSString *osVersion;
@property (nonatomic, readonly, copy) NSString *osVersion;

/**
* Operation System build string the app was running on when it crashed
*
* This may be unavailable.
*/
@property (nonatomic, readonly, strong) NSString *osBuild;
@property (nonatomic, readonly, copy) NSString *osBuild;

/**
* CFBundleShortVersionString value of the app that crashed
*
* Can be `nil` if the crash was captured with an older version of the SDK
* or if the app doesn't set the value.
*/
@property (nonatomic, readonly, strong) NSString *appVersion;
@property (nonatomic, readonly, copy) NSString *appVersion;

/**
* CFBundleVersion value of the app that crashed
*/
@property (nonatomic, readonly, strong) NSString *appBuild;
@property (nonatomic, readonly, copy) NSString *appBuild;

/**
* Identifier of the app process that crashed
Expand Down
Loading

0 comments on commit 88220e6

Please sign in to comment.