Skip to content

Commit c98cff0

Browse files
Create sync method to App Group dir
1 parent 085db09 commit c98cff0

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Diff for: fs.js

+14
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ function pathForAppGroup(groupName: string): Promise {
135135
return RNFetchBlob.pathForAppGroup(groupName)
136136
}
137137

138+
/**
139+
* Returns the path for the app group synchronous.
140+
* @param {string} groupName Name of app group
141+
* @return {string} Path of App Group dir
142+
*/
143+
function syncPathAppGroup(groupName: string): string {
144+
if (Platform.OS === 'ios') {
145+
return RNFetchBlob.syncPathAppGroup(groupName);
146+
} else {
147+
return '';
148+
}
149+
}
150+
138151
/**
139152
* Wrapper method of readStream.
140153
* @param {string} path Path of the file.
@@ -402,6 +415,7 @@ export default {
402415
writeFile,
403416
appendFile,
404417
pathForAppGroup,
418+
syncPathAppGroup,
405419
readFile,
406420
hash,
407421
exists,

Diff for: ios/RNFetchBlob/RNFetchBlob.m

+12
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ - (NSDictionary *)constantsToExport
228228
}
229229
}
230230

231+
#pragma mark - fs.syncPathAppGroup
232+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(syncPathAppGroup:(NSString *)groupName) {
233+
NSURL *pathUrl = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:groupName];
234+
NSString *path = [pathUrl path];
235+
236+
if(path) {
237+
return path;
238+
} else {
239+
return @"";
240+
}
241+
}
242+
231243
#pragma mark - fs.exists
232244
RCT_EXPORT_METHOD(exists:(NSString *)path callback:(RCTResponseSenderBlock)callback) {
233245
[RNFetchBlobFS exists:path callback:callback];

0 commit comments

Comments
 (0)