|
14 | 14 | * limitations under the License. *
|
15 | 15 | ***************************************************************************/
|
16 | 16 |
|
| 17 | +<<<<<<< HEAD |
17 | 18 | <<<<<<< HEAD
|
18 | 19 | #import <UIKit/UIKit.h>
|
19 | 20 | #import <OptimizelySDKCore/OPTLYErrorHandler.h>
|
|
24 | 25 | #import "OPTLYDatafileManager.h"
|
25 | 26 | =======
|
26 | 27 | #import "OPTLYDatafileManager.h"
|
| 28 | +======= |
| 29 | +#import <UIKit/UIKit.h> |
| 30 | +#import <OptimizelySDKCore/OPTLYLog.h> |
| 31 | +>>>>>>> Added a timer to the datafile manager to periodically download the datafile. Also moved the datafile manager protocol to core as the core should have a basic datafile downloader (the network classes will be moved to core as well in another commit.). Cleaned up the headers and was being more deligent about alphabetizing imports and initializing modules. |
27 | 32 | #import <OptimizelySDKCore/OPTLYErrorHandler.h>
|
28 |
| -#import <OptimizelySDKCore/OPTLYLogger.h> |
29 |
| -#import <OptimizelySDKCore/OPTLYNetworkService.h> |
30 | 33 | #import <OptimizelySDKShared/OPTLYDataStore.h>
|
| 34 | +<<<<<<< HEAD |
31 | 35 | >>>>>>> Moved the network manager code to the Core. This is needed for basic event dispatch and datafile download.
|
| 36 | +======= |
| 37 | +#import <OptimizelySDKShared/OPTLYNetworkService.h> |
| 38 | +#import "OPTLYDatafileManager.h" |
| 39 | +>>>>>>> Added a timer to the datafile manager to periodically download the datafile. Also moved the datafile manager protocol to core as the core should have a basic datafile downloader (the network classes will be moved to core as well in another commit.). Cleaned up the headers and was being more deligent about alphabetizing imports and initializing modules. |
32 | 40 |
|
33 | 41 | NSTimeInterval const kDefaultDatafileFetchInterval = 0;
|
34 | 42 |
|
@@ -69,16 +77,21 @@ - (instancetype)initWithBuilder:(OPTLYDatafileManagerBuilder *)builder {
|
69 | 77 | }
|
70 | 78 |
|
71 | 79 | - (void)downloadDatafile:(NSString *)projectId completionHandler:(OPTLYHTTPRequestManagerResponse)completion {
|
| 80 | +<<<<<<< HEAD |
72 | 81 | NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesDatafileManagerDatafileDownloading, projectId];
|
73 | 82 | [self.logger logMessage:logMessage withLevel:OptimizelyLogLevelInfo];
|
74 | 83 |
|
75 | 84 | NSString *lastSavedModifiedDate = [self getLastModifiedDate:projectId];
|
76 | 85 | logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesDatafileManagerLastModifiedDate, lastSavedModifiedDate];
|
77 | 86 | [self.logger logMessage:logMessage withLevel:OptimizelyLogLevelDebug];
|
78 | 87 |
|
| 88 | +======= |
| 89 | + OPTLYLogInfo(@"Downloading datafile: %@", projectId); |
| 90 | +>>>>>>> Added a timer to the datafile manager to periodically download the datafile. Also moved the datafile manager protocol to core as the core should have a basic datafile downloader (the network classes will be moved to core as well in another commit.). Cleaned up the headers and was being more deligent about alphabetizing imports and initializing modules. |
79 | 91 | [self.networkService downloadProjectConfig:self.projectId
|
80 | 92 | lastModified:lastSavedModifiedDate
|
81 | 93 | completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
| 94 | +<<<<<<< HEAD |
82 | 95 | NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
|
83 | 96 | NSInteger statusCode = [httpResponse statusCode];
|
84 | 97 | NSString *logMessage = @"";
|
@@ -115,6 +128,27 @@ - (void)downloadDatafile:(NSString *)projectId completionHandler:(OPTLYHTTPReque
|
115 | 128 | }];
|
116 | 129 | }
|
117 | 130 |
|
| 131 | +- (void)downloadDatafile { |
| 132 | + [self downloadDatafile:self.projectId completionHandler:nil]; |
| 133 | +======= |
| 134 | + if (error != nil) { |
| 135 | + [self.errorHandler handleError:error]; |
| 136 | + } |
| 137 | + else if ([(NSHTTPURLResponse *)response statusCode] == 200) { // got datafile OK |
| 138 | + [self saveDatafile:data]; |
| 139 | + OPTLYLogInfo(@"Datafile for project ID %@ downloaded. Saving datafile."); |
| 140 | + } |
| 141 | + else { |
| 142 | + // TODO: Josh W. handle bad response |
| 143 | + } |
| 144 | + // call the completion handler |
| 145 | + if (completion != nil) { |
| 146 | + completion(data, response, error); |
| 147 | + } |
| 148 | + }]; |
| 149 | +>>>>>>> Added a timer to the datafile manager to periodically download the datafile. Also moved the datafile manager protocol to core as the core should have a basic datafile downloader (the network classes will be moved to core as well in another commit.). Cleaned up the headers and was being more deligent about alphabetizing imports and initializing modules. |
| 150 | +} |
| 151 | + |
118 | 152 | - (void)downloadDatafile {
|
119 | 153 | [self downloadDatafile:self.projectId completionHandler:nil];
|
120 | 154 | }
|
@@ -159,7 +193,6 @@ - (nullable NSString *)getLastModifiedDate:(nonnull NSString *)projectId {
|
159 | 193 | return lastModifiedDate;
|
160 | 194 | }
|
161 | 195 |
|
162 |
| - |
163 | 196 | #pragma mark - Application Lifecycle Handlers
|
164 | 197 | - (void)setupApplicationNotificationHandlers {
|
165 | 198 | NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
|
|
0 commit comments