Skip to content

Commit 98b108d

Browse files
authored
Merge pull request #246 from Oktopost/master
Add pathForGroup method
2 parents ad805da + 20e60c6 commit 98b108d

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

FS.common.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ var RNFS = {
190190
return RNFSManager.pathForBundle(bundleNamed);
191191
},
192192

193+
pathForGroup(groupName: string): Promise<string> {
194+
return RNFSManager.pathForGroup(groupName);
195+
},
196+
193197
getFSInfo(): Promise<FSInfoResult> {
194198
return RNFSManager.getFSInfo();
195199
},

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Native filesystem access for react-native
2222

2323
First you need to install react-native-fs:
2424

25-
```javascript
25+
```
2626
npm install react-native-fs --save
2727
```
2828

@@ -571,6 +571,17 @@ type FSInfoResult = {
571571
};
572572
```
573573

574+
### (iOS only) `pathForGroup(groupIdentifier: string): Promise<string>`
575+
576+
`groupIdentifier` (`string`) Any value from the *com.apple.security.application-groups* entitlements list.
577+
578+
Returns the absolute path to the directory shared for all applications with the same security group identifier.
579+
This directory can be used to to share files between application of the same developer.
580+
581+
Invalid group identifier will cause a rejection.
582+
583+
For more information read the [Adding an App to an App Group](https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html#//apple_ref/doc/uid/TP40011195-CH4-SW19) section.
584+
574585
## Test / Demo app
575586

576587
Test app to demostrate the use of the module. Useful for testing and developing the module:

RNFSManager.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,19 @@ - (dispatch_queue_t)methodQueue
516516
}
517517
}
518518

519+
RCT_EXPORT_METHOD(pathForGroup:(nonnull NSString *)groupId
520+
resolver:(RCTPromiseResolveBlock)resolve
521+
rejecter:(RCTPromiseRejectBlock)reject)
522+
{
523+
NSURL *groupURL = [[NSFileManager defaultManager]containerURLForSecurityApplicationGroupIdentifier: groupId];
524+
525+
if (!groupURL) {
526+
return reject(@"ENOENT", [NSString stringWithFormat:@"ENOENT: no directory for group '%@' found", groupId], nil);
527+
} else {
528+
resolve([groupURL path]);
529+
}
530+
}
531+
519532
RCT_EXPORT_METHOD(getFSInfo:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
520533
{
521534
unsigned long long totalSpace = 0;

android/src/main/java/com/rnfs/RNFSManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,12 @@ public void stopDownload(int jobId) {
587587

588588
@ReactMethod
589589
public void pathForBundle(String bundleNamed, Promise promise) {
590-
// TODO: Not sure what equilivent would be?
590+
// TODO: Not sure what equivalent would be?
591+
}
592+
593+
@ReactMethod
594+
public void pathForGroup(String bundleNamed, Promise promise) {
595+
// TODO: Not sure what equivalent would be?
591596
}
592597

593598
@ReactMethod

0 commit comments

Comments
 (0)