forked from itinance/react-native-fs
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#27] iOS: Fixes "Background Downloads" feature + Updates related docs
- Loading branch information
1 parent
2437f8e
commit 8db8b52
Showing
6 changed files
with
120 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// RNFSBackgroundDownloads.h | ||
// Pods | ||
// | ||
// Created by Sergey Pogodin on 29/1/24. | ||
// | ||
|
||
#ifndef RNFSBackgroundDownloads_h | ||
#define RNFSBackgroundDownloads_h | ||
|
||
typedef void (^CompletionHandler)(void); | ||
|
||
@interface RNFSBackgroundDownloads: NSObject | ||
|
||
+ (void) complete:(NSString*)uuid; | ||
|
||
+ (void) setCompletionHandlerForIdentifier:(NSString*)identifier | ||
completionHandler:(CompletionHandler)completionHandler; | ||
@end | ||
|
||
#endif /* RNFSBackgroundDownloads_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// RNFSBackgroundDownloads.m | ||
// dr-pogodin-react-native-fs | ||
// | ||
// Created by Sergey Pogodin on 29/1/24. | ||
// | ||
|
||
#import "RNFSBackgroundDownloads.h" | ||
|
||
@implementation RNFSBackgroundDownloads; | ||
|
||
static NSMutableDictionary *completionHandlers; | ||
|
||
+ (void)complete:(NSString *)uuid | ||
{ | ||
CompletionHandler completionHandler = [completionHandlers objectForKey:uuid]; | ||
if (completionHandler) { | ||
completionHandler(); | ||
[completionHandlers removeObjectForKey:uuid]; | ||
} | ||
} | ||
|
||
+ (void)setCompletionHandlerForIdentifier:(NSString *)identifier completionHandler:(__strong CompletionHandler)completionHandler | ||
{ | ||
if (!completionHandlers) completionHandlers = [[NSMutableDictionary alloc] init]; | ||
[completionHandlers setValue:completionHandler forKey:identifier]; | ||
} | ||
|
||
@end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters