-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds CTFileDownloadManager class for file downloading Adds callback for each file and all files download * Added unit tests for CTFileDownloadManager * Added unit tests for CTFileDownloadDelegate protocol callback methods. * Updated callback approach to use completion block. Updated unit tests. * - Added class CTFileDownloader to handle file downloading from inapps, file variables. - Added expiry logic for files downloaded. - Added unit tests. * Added public method to get file downloaded path. * Added some unit tests for clearFileAssets method. * - Added logic for handling url download in progress, only one request to the url to download the file. - Added methods for image preloading cases. - Added unit test cases. * - Added thread safety check for updating active and inactive dictionary. - Added changes for CS InApps to use the new CTFileDownloader class for image preloading. - Removed previous usage of CTInAppImagePrefetchManager class for image preloading. * Added callback for File variables only, and code cleanup. * Address comments and improvements * Rename methods * Move duplicate methods to test helper * Move tests to group * Move tests headers and mocks to separate files * Use longer resource timeout * Improve tests * Improve clear expired files * Fix clear expired assets * Save files to directory inside documents Remove all files removes the files inside the directory Add Unit tests * Move to group --------- Co-authored-by: Nikola Zagorchev <[email protected]>
- Loading branch information
1 parent
40f069d
commit 6a94ad3
Showing
36 changed files
with
2,140 additions
and
669 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,68 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@class CleverTapInstanceConfig; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef void(^CTFilesDownloadCompletedBlock)(NSDictionary<NSString *, NSNumber *> *status); | ||
typedef void(^CTFilesDeleteCompletedBlock)(NSDictionary<NSString *, NSNumber *> *status); | ||
typedef void(^CTFilesRemoveCompletedBlock)(NSDictionary<NSString *, NSNumber *> *status); | ||
typedef void (^DownloadCompletionHandler)(NSURL *url, BOOL success); | ||
|
||
@interface CTFileDownloadManager : NSObject | ||
|
||
+ (instancetype)sharedInstanceWithConfig:(CleverTapInstanceConfig *)config; | ||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
/*! | ||
@method | ||
@discussion | ||
This method accepts file urls as NSArray of NSURLs and downloads each file to directory inside NSDocumentDirectory directory. | ||
@param completion the completion block to be executed when all files are downloaded. `status` dictionary will | ||
contain file download status of each file as {url,success}. The completion block is executed on background queue. | ||
*/ | ||
- (void)downloadFiles:(NSArray<NSURL *> *)urls withCompletionBlock:(CTFilesDownloadCompletedBlock)completion; | ||
|
||
/*! | ||
@method | ||
@discussion | ||
This method checks if file is already present in the directory or not. | ||
*/ | ||
- (BOOL)isFileAlreadyPresent:(NSURL *)url; | ||
|
||
/*! | ||
@method | ||
@discussion | ||
This method returns the file path to the file. This method does *not* check if the file exists. | ||
*/ | ||
- (NSString *)filePath:(NSURL *)url; | ||
|
||
/*! | ||
@method | ||
@discussion | ||
This method deletes the files from the directory if present. | ||
@param completion the completion block to be executed when all files are deleted. `status` dictionary will | ||
contain file delete status of each file as {url,success}. The completion block is executed on background queue. | ||
*/ | ||
- (void)deleteFiles:(NSArray<NSString *> *)urls withCompletionBlock:(CTFilesDeleteCompletedBlock)completion; | ||
|
||
/*! | ||
@method | ||
@discussion | ||
This method deletes all files from the directory. | ||
@param completion the completion block to be executed when all files are deleted. `status` dictionary will | ||
contain file download status of each file as {file path,success}. The completion block is executed on background queue. | ||
*/ | ||
- (void)removeAllFilesWithCompletionBlock:(CTFilesRemoveCompletedBlock)completion; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.