Skip to content

Commit

Permalink
Version 2.8.0 (#117)
Browse files Browse the repository at this point in the history
* add REPORT flag request
  • Loading branch information
arun251 authored Oct 13, 2017
1 parent 64f29f5 commit 0296ab4
Show file tree
Hide file tree
Showing 15 changed files with 586 additions and 161 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## [2.8.0] - 2017-10-13
### Added
- `useReport` property on `LDConfig` to allow switching the request verb from `GET` to `REPORT`. Do not use unless advised by LaunchDarkly.

## [2.7.0] - 2017-09-25
### Changed
- Updated for Xcode 9 support
Expand Down
6 changes: 6 additions & 0 deletions Darkly.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
833D08D21F3B97EB00BEED83 /* NSThread+MainExecutable.m in Sources */ = {isa = PBXBuildFile; fileRef = 833D08CA1F3B97EB00BEED83 /* NSThread+MainExecutable.m */; };
8349F51E1F19352300B1F3DB /* NSDictionary+StringKey_Matchable.m in Sources */ = {isa = PBXBuildFile; fileRef = 8349F51D1F19352300B1F3DB /* NSDictionary+StringKey_Matchable.m */; };
8349F5211F195BCF00B1F3DB /* LDUserModel+Equatable.m in Sources */ = {isa = PBXBuildFile; fileRef = 8349F5201F195BCF00B1F3DB /* LDUserModel+Equatable.m */; };
8358F25A1F4202A300ECE1AF /* LDConfig+Testable.m in Sources */ = {isa = PBXBuildFile; fileRef = 8358F2591F4202A300ECE1AF /* LDConfig+Testable.m */; };
8369475C1F1FED400047697C /* boolConfigIsABool-false.json in Resources */ = {isa = PBXBuildFile; fileRef = 836947591F1FED400047697C /* boolConfigIsABool-false.json */; };
8369475D1F1FED400047697C /* boolConfigIsABool-true.json in Resources */ = {isa = PBXBuildFile; fileRef = 8369475A1F1FED400047697C /* boolConfigIsABool-true.json */; };
8369475E1F1FED400047697C /* boolConfigIsABool2-true.json in Resources */ = {isa = PBXBuildFile; fileRef = 8369475B1F1FED400047697C /* boolConfigIsABool2-true.json */; };
Expand Down Expand Up @@ -273,6 +274,8 @@
8349F51D1F19352300B1F3DB /* NSDictionary+StringKey_Matchable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+StringKey_Matchable.m"; sourceTree = "<group>"; };
8349F51F1F195BCF00B1F3DB /* LDUserModel+Equatable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "LDUserModel+Equatable.h"; sourceTree = "<group>"; };
8349F5201F195BCF00B1F3DB /* LDUserModel+Equatable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "LDUserModel+Equatable.m"; sourceTree = "<group>"; };
8358F2581F4202A300ECE1AF /* LDConfig+Testable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "LDConfig+Testable.h"; sourceTree = "<group>"; };
8358F2591F4202A300ECE1AF /* LDConfig+Testable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "LDConfig+Testable.m"; sourceTree = "<group>"; };
836947591F1FED400047697C /* boolConfigIsABool-false.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "boolConfigIsABool-false.json"; sourceTree = "<group>"; };
8369475A1F1FED400047697C /* boolConfigIsABool-true.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "boolConfigIsABool-true.json"; sourceTree = "<group>"; };
8369475B1F1FED400047697C /* boolConfigIsABool2-true.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "boolConfigIsABool2-true.json"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -501,6 +504,8 @@
83258A3C1F323049008C2133 /* LDClientManager+EventSource.m */,
83258A3E1F3244D0008C2133 /* LDUserBuilder+Testable.h */,
83258A3F1F3244D0008C2133 /* LDUserBuilder+Testable.m */,
8358F2581F4202A300ECE1AF /* LDConfig+Testable.h */,
8358F2591F4202A300ECE1AF /* LDConfig+Testable.m */,
);
path = Categories;
sourceTree = "<group>";
Expand Down Expand Up @@ -1082,6 +1087,7 @@
690347331E689B9F00E45133 /* NSArray+UnitTests.m in Sources */,
6903472C1E689B9F00E45133 /* LDClientTest.m in Sources */,
832C78901F2A8DF600E334A2 /* LDUserModel+JsonDecodeable.m in Sources */,
8358F25A1F4202A300ECE1AF /* LDConfig+Testable.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
3 changes: 3 additions & 0 deletions Darkly/DarklyConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ extern int const kMinimumPollingInterval;
extern int const kDefaultBackgroundFetchInterval;
extern int const kMinimumBackgroundFetchInterval;
extern int const kMillisInSecs;
extern NSInteger const kHTTPStatusCodeBadRequest;
extern NSInteger const kHTTPStatusCodeMethodNotAllowed;
extern NSInteger const kHTTPStatusCodeNotImplemented;
5 changes: 4 additions & 1 deletion Darkly/DarklyConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#import "DarklyConstants.h"

NSString * const kClientVersion = @"2.7.0";
NSString * const kClientVersion = @"2.8.0";
NSString * const kBaseUrl = @"https://app.launchdarkly.com";
NSString * const kEventsUrl = @"https://mobile.launchdarkly.com";
NSString * const kStreamUrl = @"https://clientstream.launchdarkly.com/mping";
Expand Down Expand Up @@ -36,3 +36,6 @@
int const kDefaultBackgroundFetchInterval = 3600;
int const kMinimumBackgroundFetchInterval = 900;
int const kMillisInSecs = 1000;
NSInteger const kHTTPStatusCodeBadRequest = 400;
NSInteger const kHTTPStatusCodeMethodNotAllowed = 405;
NSInteger const kHTTPStatusCodeNotImplemented = 501;
26 changes: 9 additions & 17 deletions Darkly/LDClientManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,17 @@ -(void)syncWithServerForEvents {
}

-(void)syncWithServerForConfig {
if (!offlineEnabled) {
DEBUG_LOGX(@"ClientManager syncing config with server");
LDClient *client = [LDClient sharedInstance];
LDUserModel *currentUser = client.ldUser;

if (currentUser) {
NSString *jsonString = [currentUser convertToJson];
if (jsonString) {
NSString *encodedUser = [LDUtil base64UrlEncodeString:jsonString];
[[LDRequestManager sharedInstance] performFeatureFlagRequest:encodedUser];
} else {
DEBUG_LOGX(@"ClientManager is not able to convert user to json");
}
} else {
DEBUG_LOGX(@"ClientManager has no user so won't sync config with server");
}
} else {
if (offlineEnabled) {
DEBUG_LOGX(@"ClientManager is in offline mode so won't sync config with server");
return;
}

if (![LDClient sharedInstance].ldUser) {
DEBUG_LOGX(@"ClientManager has no user so won't sync config with server");
return;
}

[[LDRequestManager sharedInstance] performFeatureFlagRequest:[LDClient sharedInstance].ldUser];
}

- (void)flushEvents {
Expand Down
8 changes: 8 additions & 0 deletions Darkly/LDConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
*/
@property (nonatomic) BOOL streaming;

/**
Flag that enables REPORT HTTP method for feature flag requests. When useReport is false,
feature flag requests use the GET HTTP method. The default is NO.
Do not use unless advised by LaunchDarkly.
*/
@property (nonatomic, assign) BOOL useReport;

/**
Flag that enables debug mode to allow things such as logging.
*/
Expand All @@ -80,6 +87,7 @@
@return An instance of LDConfig object.
*/
- (instancetype _Nonnull)initWithMobileKey:(nonnull NSString *)mobileKey NS_DESIGNATED_INITIALIZER;
- (BOOL)isFlagRetryStatusCode:(NSInteger)statusCode;

- (instancetype _Nonnull )init NS_UNAVAILABLE;

Expand Down
10 changes: 10 additions & 0 deletions Darkly/LDConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

@interface LDConfig()
@property (nonatomic, copy, nonnull) NSString* mobileKey;
@property (nonatomic, strong, nonnull) NSArray<NSNumber*> *flagRetryStatusCodes;
@end

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

return self;
}
Expand Down Expand Up @@ -115,6 +121,10 @@ - (void)setDebugEnabled:(BOOL)debugEnabled {
DEBUG_LOG(@"Set LDConfig debug enabled: %d", debugEnabled);
}

- (BOOL)isFlagRetryStatusCode:(NSInteger)statusCode {
return [self.flagRetryStatusCodes containsObject:@(statusCode)];
}

@end


Expand Down
9 changes: 3 additions & 6 deletions Darkly/LDRequestManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Copyright © 2015 Catamorphic Co. All rights reserved.
//


#import "LDFlagConfigModel.h"
#import "LDUserModel.h"

@protocol RequestManagerDelegate <NSObject>

Expand All @@ -12,9 +11,7 @@

@end

@interface LDRequestManager : NSObject {

}
@interface LDRequestManager : NSObject

extern NSString * const kHeaderMobileKey;
@property (nonatomic) NSString* mobileKey;
Expand All @@ -25,7 +22,7 @@ extern NSString * const kHeaderMobileKey;

+(LDRequestManager *)sharedInstance;

-(void)performFeatureFlagRequest:(NSString *)encodedUser;
-(void)performFeatureFlagRequest:(LDUserModel *)user;

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

Expand Down
Loading

0 comments on commit 0296ab4

Please sign in to comment.