File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
iOS_SDK/OneSignalSDK/Source Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,23 @@ @implementation DirectDownloadDelegate
7575@synthesize error, response, done;
7676
7777-(void )URLSession : (NSURLSession *)session dataTask : (NSURLSessionDataTask *)dataTask didReceiveData : (NSData *)data {
78- [outputHandle writeData: data];
78+ NSError *fileHandleError;
79+ if (@available (iOS 13.0 , *)) {
80+ [outputHandle writeData: data error: &fileHandleError];
81+ } else {
82+ @try {
83+ [outputHandle writeData: data];
84+ } @catch (NSException *e) {
85+ NSDictionary *userInfo = @{
86+ NSLocalizedDescriptionKey : @" Failed to write attachment data to filehandle" ,
87+ };
88+ fileHandleError = [NSError errorWithDomain: @" com.onesignal.download" code: 0 userInfo: userInfo];
89+ }
90+ }
91+
92+ if (fileHandleError != nil ) {
93+ [OneSignal onesignalLog: ONE_S_LL_ERROR message: [NSString stringWithFormat: @" OneSignal Error encountered while downloading attachment: %@ " , fileHandleError.localizedDescription]];
94+ }
7995}
8096
8197- (void )URLSession : (NSURLSession *)session dataTask : (NSURLSessionDataTask *)dataTask didReceiveResponse : (NSURLResponse *)aResponse completionHandler : (void (^)(NSURLSessionResponseDisposition ))completionHandler {
You can’t perform that action at this time.
0 commit comments