Skip to content

Commit 0296ab4

Browse files
authored
Version 2.8.0 (#117)
* add REPORT flag request
1 parent 64f29f5 commit 0296ab4

15 files changed

+586
-161
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to the LaunchDarkly iOS SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [2.8.0] - 2017-10-13
6+
### Added
7+
- `useReport` property on `LDConfig` to allow switching the request verb from `GET` to `REPORT`. Do not use unless advised by LaunchDarkly.
8+
59
## [2.7.0] - 2017-09-25
610
### Changed
711
- Updated for Xcode 9 support

Darkly.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
833D08D21F3B97EB00BEED83 /* NSThread+MainExecutable.m in Sources */ = {isa = PBXBuildFile; fileRef = 833D08CA1F3B97EB00BEED83 /* NSThread+MainExecutable.m */; };
162162
8349F51E1F19352300B1F3DB /* NSDictionary+StringKey_Matchable.m in Sources */ = {isa = PBXBuildFile; fileRef = 8349F51D1F19352300B1F3DB /* NSDictionary+StringKey_Matchable.m */; };
163163
8349F5211F195BCF00B1F3DB /* LDUserModel+Equatable.m in Sources */ = {isa = PBXBuildFile; fileRef = 8349F5201F195BCF00B1F3DB /* LDUserModel+Equatable.m */; };
164+
8358F25A1F4202A300ECE1AF /* LDConfig+Testable.m in Sources */ = {isa = PBXBuildFile; fileRef = 8358F2591F4202A300ECE1AF /* LDConfig+Testable.m */; };
164165
8369475C1F1FED400047697C /* boolConfigIsABool-false.json in Resources */ = {isa = PBXBuildFile; fileRef = 836947591F1FED400047697C /* boolConfigIsABool-false.json */; };
165166
8369475D1F1FED400047697C /* boolConfigIsABool-true.json in Resources */ = {isa = PBXBuildFile; fileRef = 8369475A1F1FED400047697C /* boolConfigIsABool-true.json */; };
166167
8369475E1F1FED400047697C /* boolConfigIsABool2-true.json in Resources */ = {isa = PBXBuildFile; fileRef = 8369475B1F1FED400047697C /* boolConfigIsABool2-true.json */; };
@@ -273,6 +274,8 @@
273274
8349F51D1F19352300B1F3DB /* NSDictionary+StringKey_Matchable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+StringKey_Matchable.m"; sourceTree = "<group>"; };
274275
8349F51F1F195BCF00B1F3DB /* LDUserModel+Equatable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "LDUserModel+Equatable.h"; sourceTree = "<group>"; };
275276
8349F5201F195BCF00B1F3DB /* LDUserModel+Equatable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "LDUserModel+Equatable.m"; sourceTree = "<group>"; };
277+
8358F2581F4202A300ECE1AF /* LDConfig+Testable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "LDConfig+Testable.h"; sourceTree = "<group>"; };
278+
8358F2591F4202A300ECE1AF /* LDConfig+Testable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "LDConfig+Testable.m"; sourceTree = "<group>"; };
276279
836947591F1FED400047697C /* boolConfigIsABool-false.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "boolConfigIsABool-false.json"; sourceTree = "<group>"; };
277280
8369475A1F1FED400047697C /* boolConfigIsABool-true.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "boolConfigIsABool-true.json"; sourceTree = "<group>"; };
278281
8369475B1F1FED400047697C /* boolConfigIsABool2-true.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "boolConfigIsABool2-true.json"; sourceTree = "<group>"; };
@@ -501,6 +504,8 @@
501504
83258A3C1F323049008C2133 /* LDClientManager+EventSource.m */,
502505
83258A3E1F3244D0008C2133 /* LDUserBuilder+Testable.h */,
503506
83258A3F1F3244D0008C2133 /* LDUserBuilder+Testable.m */,
507+
8358F2581F4202A300ECE1AF /* LDConfig+Testable.h */,
508+
8358F2591F4202A300ECE1AF /* LDConfig+Testable.m */,
504509
);
505510
path = Categories;
506511
sourceTree = "<group>";
@@ -1082,6 +1087,7 @@
10821087
690347331E689B9F00E45133 /* NSArray+UnitTests.m in Sources */,
10831088
6903472C1E689B9F00E45133 /* LDClientTest.m in Sources */,
10841089
832C78901F2A8DF600E334A2 /* LDUserModel+JsonDecodeable.m in Sources */,
1090+
8358F25A1F4202A300ECE1AF /* LDConfig+Testable.m in Sources */,
10851091
);
10861092
runOnlyForDeploymentPostprocessing = 0;
10871093
};

Darkly/DarklyConstants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ extern int const kMinimumPollingInterval;
4949
extern int const kDefaultBackgroundFetchInterval;
5050
extern int const kMinimumBackgroundFetchInterval;
5151
extern int const kMillisInSecs;
52+
extern NSInteger const kHTTPStatusCodeBadRequest;
53+
extern NSInteger const kHTTPStatusCodeMethodNotAllowed;
54+
extern NSInteger const kHTTPStatusCodeNotImplemented;

Darkly/DarklyConstants.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#import "DarklyConstants.h"
66

7-
NSString * const kClientVersion = @"2.7.0";
7+
NSString * const kClientVersion = @"2.8.0";
88
NSString * const kBaseUrl = @"https://app.launchdarkly.com";
99
NSString * const kEventsUrl = @"https://mobile.launchdarkly.com";
1010
NSString * const kStreamUrl = @"https://clientstream.launchdarkly.com/mping";
@@ -36,3 +36,6 @@
3636
int const kDefaultBackgroundFetchInterval = 3600;
3737
int const kMinimumBackgroundFetchInterval = 900;
3838
int const kMillisInSecs = 1000;
39+
NSInteger const kHTTPStatusCodeBadRequest = 400;
40+
NSInteger const kHTTPStatusCodeMethodNotAllowed = 405;
41+
NSInteger const kHTTPStatusCodeNotImplemented = 501;

Darkly/LDClientManager.m

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,25 +158,17 @@ -(void)syncWithServerForEvents {
158158
}
159159

160160
-(void)syncWithServerForConfig {
161-
if (!offlineEnabled) {
162-
DEBUG_LOGX(@"ClientManager syncing config with server");
163-
LDClient *client = [LDClient sharedInstance];
164-
LDUserModel *currentUser = client.ldUser;
165-
166-
if (currentUser) {
167-
NSString *jsonString = [currentUser convertToJson];
168-
if (jsonString) {
169-
NSString *encodedUser = [LDUtil base64UrlEncodeString:jsonString];
170-
[[LDRequestManager sharedInstance] performFeatureFlagRequest:encodedUser];
171-
} else {
172-
DEBUG_LOGX(@"ClientManager is not able to convert user to json");
173-
}
174-
} else {
175-
DEBUG_LOGX(@"ClientManager has no user so won't sync config with server");
176-
}
177-
} else {
161+
if (offlineEnabled) {
178162
DEBUG_LOGX(@"ClientManager is in offline mode so won't sync config with server");
163+
return;
179164
}
165+
166+
if (![LDClient sharedInstance].ldUser) {
167+
DEBUG_LOGX(@"ClientManager has no user so won't sync config with server");
168+
return;
169+
}
170+
171+
[[LDRequestManager sharedInstance] performFeatureFlagRequest:[LDClient sharedInstance].ldUser];
180172
}
181173

182174
- (void)flushEvents {

Darkly/LDConfig.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
*/
7070
@property (nonatomic) BOOL streaming;
7171

72+
/**
73+
Flag that enables REPORT HTTP method for feature flag requests. When useReport is false,
74+
feature flag requests use the GET HTTP method. The default is NO.
75+
Do not use unless advised by LaunchDarkly.
76+
*/
77+
@property (nonatomic, assign) BOOL useReport;
78+
7279
/**
7380
Flag that enables debug mode to allow things such as logging.
7481
*/
@@ -80,6 +87,7 @@
8087
@return An instance of LDConfig object.
8188
*/
8289
- (instancetype _Nonnull)initWithMobileKey:(nonnull NSString *)mobileKey NS_DESIGNATED_INITIALIZER;
90+
- (BOOL)isFlagRetryStatusCode:(NSInteger)statusCode;
8391

8492
- (instancetype _Nonnull )init NS_UNAVAILABLE;
8593

Darkly/LDConfig.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
@interface LDConfig()
99
@property (nonatomic, copy, nonnull) NSString* mobileKey;
10+
@property (nonatomic, strong, nonnull) NSArray<NSNumber*> *flagRetryStatusCodes;
1011
@end
1112

1213
@implementation LDConfig
@@ -26,6 +27,11 @@ - (instancetype)initWithMobileKey:(NSString *)mobileKey {
2627
self.baseUrl = kBaseUrl;
2728
self.eventsUrl = kEventsUrl;
2829
self.streamUrl = kStreamUrl;
30+
// self.flagRetryStatusCodes = @[@(kHTTPStatusCodeMethodNotAllowed),
31+
// @(kHTTPStatusCodeBadRequest),
32+
// @(kHTTPStatusCodeNotImplemented)];
33+
self.flagRetryStatusCodes = @[]; //Temporarily, leave these codes empty to disable the REPORT fallback using GET capability
34+
self.useReport = NO;
2935

3036
return self;
3137
}
@@ -115,6 +121,10 @@ - (void)setDebugEnabled:(BOOL)debugEnabled {
115121
DEBUG_LOG(@"Set LDConfig debug enabled: %d", debugEnabled);
116122
}
117123

124+
- (BOOL)isFlagRetryStatusCode:(NSInteger)statusCode {
125+
return [self.flagRetryStatusCodes containsObject:@(statusCode)];
126+
}
127+
118128
@end
119129

120130

Darkly/LDRequestManager.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright © 2015 Catamorphic Co. All rights reserved.
33
//
44

5-
6-
#import "LDFlagConfigModel.h"
5+
#import "LDUserModel.h"
76

87
@protocol RequestManagerDelegate <NSObject>
98

@@ -12,9 +11,7 @@
1211

1312
@end
1413

15-
@interface LDRequestManager : NSObject {
16-
17-
}
14+
@interface LDRequestManager : NSObject
1815

1916
extern NSString * const kHeaderMobileKey;
2017
@property (nonatomic) NSString* mobileKey;
@@ -25,7 +22,7 @@ extern NSString * const kHeaderMobileKey;
2522

2623
+(LDRequestManager *)sharedInstance;
2724

28-
-(void)performFeatureFlagRequest:(NSString *)encodedUser;
25+
-(void)performFeatureFlagRequest:(LDUserModel *)user;
2926

3027
-(void)performEventRequest:(NSArray *)jsonEventArray;
3128

0 commit comments

Comments
 (0)