Skip to content

Commit 03ded5e

Browse files
committed
bid app key farewell
1 parent d6f2090 commit 03ded5e

File tree

6 files changed

+12
-81
lines changed

6 files changed

+12
-81
lines changed

Branch-SDK/Branch-SDK/BNCPreferenceHelper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
@interface BNCPreferenceHelper : NSObject
1515

1616
@property (strong, nonatomic) NSString *branchKey;
17-
@property (strong, nonatomic) NSString *appKey;
1817
@property (strong, nonatomic) NSString *lastRunBranchKey;
1918
@property (strong, nonatomic) NSDate *lastStrongMatchDate;
2019
@property (strong, nonatomic) NSString *appVersion;

Branch-SDK/Branch-SDK/BNCPreferenceHelper.m

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
NSString * const BRANCH_PREFS_FILE = @"BNCPreferences";
2020

21-
NSString * const BRANCH_PREFS_KEY_APP_KEY = @"bnc_app_key";
2221
NSString * const BRANCH_PREFS_KEY_APP_VERSION = @"bnc_app_version";
2322
NSString * const BRANCH_PREFS_KEY_LAST_RUN_BRANCH_KEY = @"bnc_last_run_branch_key";
2423
NSString * const BRANCH_PREFS_KEY_LAST_STRONG_MATCH_DATE = @"bnc_strong_match_created_date";
@@ -63,7 +62,6 @@ @interface BNCPreferenceHelper ()
6362
@implementation BNCPreferenceHelper
6463

6564
@synthesize branchKey = _branchKey,
66-
appKey = _appKey,
6765
lastRunBranchKey = _lastRunBranchKey,
6866
appVersion = _appVersion,
6967
deviceFingerprintID = _deviceFingerprintID,
@@ -170,23 +168,6 @@ - (NSString *)getEndpointFromURL:(NSString *)url {
170168
}
171169
#pragma mark - Preference Storage
172170

173-
- (NSString *)appKey {
174-
if (!_appKey) {
175-
_appKey = [[[NSBundle mainBundle] infoDictionary] objectForKey:BRANCH_PREFS_KEY_APP_KEY];
176-
}
177-
178-
return _appKey;
179-
}
180-
181-
- (void)setAppKey:(NSString *)appKey {
182-
NSLog(@"Usage of App Key is deprecated, please move toward using a Branch key");
183-
184-
if (![_appKey isEqualToString:appKey]) {
185-
_appKey = appKey;
186-
[self writeObjectToDefaults:BRANCH_PREFS_KEY_APP_KEY value:appKey];
187-
}
188-
}
189-
190171
- (NSString *)getBranchKey:(BOOL)isLive {
191172
// Already loaded a key, and it's the same state (live/test)
192173
if (_branchKey && isLive == self.isUsingLiveKey) {

Branch-SDK/Branch-SDK/BNCServerInterface.m

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,16 @@ - (NSDictionary *)prepareParamDict:(NSDictionary *)params key:(NSString *)key re
231231
[fullParamDict addEntriesFromDictionary:params];
232232
fullParamDict[@"sdk"] = [NSString stringWithFormat:@"ios%@", SDK_VERSION];
233233
fullParamDict[@"retryNumber"] = @(retryNumber);
234-
234+
fullParamDict[@"branch_key"] = key;
235+
235236
NSMutableDictionary *metadata = [[NSMutableDictionary alloc] init];
236237
[metadata addEntriesFromDictionary:self.preferenceHelper.requestMetadataDictionary];
237238
[metadata addEntriesFromDictionary:fullParamDict[BRANCH_REQUEST_KEY_STATE]];
238239
fullParamDict[BRANCH_REQUEST_KEY_STATE] = metadata;
239240
if (self.preferenceHelper.instrumentationDictionary.count) {
240241
fullParamDict[BRANCH_REQUEST_KEY_INSTRUMENTATION] = self.preferenceHelper.instrumentationDictionary;
241242
}
242-
if ([key hasPrefix:@"key_"]) {
243-
fullParamDict[@"branch_key"] = key;
244-
}
245-
else {
246-
fullParamDict[@"app_id"] = key;
247-
}
248-
243+
249244
return fullParamDict;
250245
}
251246

Branch-SDK/Branch-SDK/BNCStrongMatchHelper.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ - (void)presentSafariVCWithBranchKey:(NSString *)branchKey {
100100
}
101101

102102
if (branchKey) {
103-
if ([branchKey hasPrefix:@"key_"]) {
104-
[urlString appendFormat:@"&branch_key=%@", branchKey];
105-
}
106-
else {
107-
[urlString appendFormat:@"&app_id=%@", branchKey];
108-
}
103+
[urlString appendFormat:@"&branch_key=%@", branchKey];
109104
}
110105

111106
[urlString appendFormat:@"&sdk=ios%@", SDK_VERSION];

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,10 @@ + (Branch *)getInstance {
102102
NSString *branchKey = [preferenceHelper getBranchKey:YES];
103103
NSString *keyToUse = branchKey;
104104
if (!branchKey) {
105-
// If no app key
106-
NSString *appKey = preferenceHelper.appKey;
107-
if (!appKey) {
108-
[preferenceHelper logWarning:@"Please enter your branch_key in the plist!"];
109-
return nil;
110-
}
111-
else {
112-
keyToUse = appKey;
113-
NSLog(@"Usage of App Key is deprecated, please move toward using a Branch key");
114-
}
105+
[preferenceHelper logWarning:@"Please enter your branch_key in the plist!"];
106+
return nil;
115107
}
116-
108+
117109
return [Branch getInstanceInternal:keyToUse returnNilIfNoCurrentInstance:NO];
118110
}
119111

@@ -124,17 +116,8 @@ + (Branch *)getTestInstance {
124116
NSString *branchKey = [preferenceHelper getBranchKey:NO];
125117
NSString *keyToUse = branchKey;
126118
if (!branchKey) {
127-
// If no app key
128-
NSString *appKey = preferenceHelper.appKey;
129-
if (!appKey) {
130-
[preferenceHelper logWarning:@"Please enter your branch_key in the plist!"];
131-
return nil;
132-
}
133-
// If they did provide an app key, show them a warning. Shouldn't use app key with a test instance.
134-
else {
135-
[preferenceHelper logWarning:@"You requested the test instance, but provided an app key. App Keys cannot be used for test instances. Additionally, usage of App Key is deprecated, please move toward using a Branch key"];
136-
keyToUse = appKey;
137-
}
119+
[preferenceHelper logWarning:@"Please enter your branch_key in the plist!"];
120+
return nil;
138121
}
139122

140123
return [Branch getInstanceInternal:keyToUse returnNilIfNoCurrentInstance:NO];
@@ -143,11 +126,12 @@ + (Branch *)getTestInstance {
143126
+ (Branch *)getInstance:(NSString *)branchKey {
144127
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper preferenceHelper];
145128

146-
if ([branchKey rangeOfString:@"key_"].location != NSNotFound) {
129+
if ([branchKey hasPrefix:@"key_"]) {
147130
preferenceHelper.branchKey = branchKey;
148131
}
149132
else {
150-
preferenceHelper.appKey = branchKey;
133+
[preferenceHelper logWarning:@"Invalid Branch Key format!"];
134+
return nil;
151135
}
152136

153137
return [Branch getInstanceInternal:branchKey returnNilIfNoCurrentInstance:NO];

Branch-TestBed/Branch-SDK-Tests/BNCServerInterfaceTests.m

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,6 @@ - (void)testParamAddForBranchKey {
5757

5858
}
5959

60-
//==================================================================================
61-
//TEST 02
62-
//This test checks to see that the branch key has been added to the GET request
63-
64-
- (void)testParamAddForAppKey {
65-
BNCServerInterface *serverInterface = [[BNCServerInterface alloc] init];
66-
XCTestExpectation* expectation = [self expectationWithDescription:@"NSURLSessionDataTask completed"];
67-
68-
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
69-
// We're not sending a request, just verifying a "branch_key=key_foo" is present.
70-
XCTAssertTrue([request.URL.query rangeOfString:@"app_id=non_branch_key"].location != NSNotFound, @"Branch App ID not added");
71-
[expectation fulfill];
72-
return [request.URL.query rangeOfString:@"app_id=key_foo"].location != NSNotFound;
73-
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
74-
NSDictionary* dummyJSONResponse = @{@"key": @"value"};
75-
return [OHHTTPStubsResponse responseWithJSONObject:dummyJSONResponse statusCode:200 headers:nil];
76-
}];
77-
78-
[serverInterface getRequest:nil url:@"http://foo" key:@"non_branch_key" callback:NULL];
79-
80-
[self waitForExpectationsWithTimeout:5.0 /* 5 seconds */ handler:nil];
81-
}
82-
8360
#pragma mark - Retry tests
8461

8562
//==================================================================================

0 commit comments

Comments
 (0)