Skip to content

Commit 943ab31

Browse files
committed
Removed param urlString from BranchOpenRequest class
urlString holds the same value as linkparams.referringURL. So removed urlString and adjusted other functions to use linkparams.referringURL instead.
1 parent f195d92 commit 943ab31

File tree

6 files changed

+27
-30
lines changed

6 files changed

+27
-30
lines changed

Sources/BranchSDK/BNCRequestFactory.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ - (BOOL)isTrackingDisabled {
8282
return Branch.trackingDisabled;
8383
}
8484

85-
- (NSDictionary *)dataForInstallWithRequestObject:(BranchInstallRequest *) installRequest {
85+
- (NSDictionary *)dataForInstallWithLinkParams:(BranchOpenRequestLinkParams *) linkParams {
8686
NSMutableDictionary *json = [NSMutableDictionary new];
8787

8888
// All requests
@@ -101,18 +101,18 @@ - (NSDictionary *)dataForInstallWithRequestObject:(BranchInstallRequest *) insta
101101
// Install and Open
102102
[self addDeveloperUserIDToJSON:json];
103103
[self addSystemObserverDataToJSON:json];
104-
[self addOpenRequestDataToJSON:json fromRequestObject:installRequest];
104+
[self addOpenRequestDataToJSON:json fromLinkParams:linkParams];
105105
[self addPartnerParametersToJSON:json];
106106
[self addAppleReceiptSourceToJSON:json];
107107
[self addTimestampsToJSON:json];
108108

109109
// Check if the urlString is a valid URL to ensure it's a universal link, not the external intent uri
110-
if (installRequest.urlString && !installRequest.linkParams.dropURLOpen) {
111-
NSURL *url = [NSURL URLWithString:installRequest.urlString];
110+
if (linkParams.referringURL && !linkParams.dropURLOpen) {
111+
NSURL *url = [NSURL URLWithString:linkParams.referringURL];
112112
if (url && ([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"])) {
113-
[self safeSetValue:installRequest.urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
113+
[self safeSetValue:linkParams.referringURL forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
114114
} else {
115-
[self safeSetValue:installRequest.urlString forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json];
115+
[self safeSetValue:linkParams.referringURL forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json];
116116
}
117117
}
118118

@@ -134,7 +134,7 @@ - (NSDictionary *)dataForInstallWithRequestObject:(BranchInstallRequest *) insta
134134
return json;
135135
}
136136

137-
- (NSDictionary *)dataForOpenWithRequestObject:(BranchOpenRequest *) openRequest {
137+
- (NSDictionary *)dataForOpenWithLinkParams:(BranchOpenRequestLinkParams *) linkParams{
138138
NSMutableDictionary *json = [NSMutableDictionary new];
139139

140140
// All requests
@@ -156,19 +156,19 @@ - (NSDictionary *)dataForOpenWithRequestObject:(BranchOpenRequest *) openRequest
156156
// Install and Open
157157
[self addDeveloperUserIDToJSON:json];
158158
[self addSystemObserverDataToJSON:json];
159-
[self addOpenRequestDataToJSON:json fromRequestObject:openRequest];
159+
[self addOpenRequestDataToJSON:json fromLinkParams:linkParams];
160160
[self addPartnerParametersToJSON:json];
161161
[self addAppleReceiptSourceToJSON:json];
162162
[self addTimestampsToJSON:json];
163163

164164

165165
// Check if the urlString is a valid URL to ensure it's a universal link, not the external intent uri
166-
if (openRequest.urlString && !openRequest.linkParams.dropURLOpen) {
167-
NSURL *url = [NSURL URLWithString:openRequest.urlString];
166+
if (linkParams.referringURL && !linkParams.dropURLOpen) {
167+
NSURL *url = [NSURL URLWithString:linkParams.referringURL];
168168
if (url && ([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"])) {
169-
[self safeSetValue:openRequest.urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
169+
[self safeSetValue:linkParams.referringURL forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
170170
} else {
171-
[self safeSetValue:openRequest.urlString forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json];
171+
[self safeSetValue:linkParams.referringURL forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json];
172172
}
173173
}
174174

@@ -305,12 +305,12 @@ - (void)addShortURLTokensToJSON:(NSMutableDictionary *)json isSpotlightRequest:(
305305
json[BRANCH_REQUEST_KEY_SESSION_ID] = self.preferenceHelper.sessionID;
306306
}
307307

308-
- (void)addOpenRequestDataToJSON:(NSMutableDictionary *)json fromRequestObject:(BranchOpenRequest *) openRequest{
308+
- (void)addOpenRequestDataToJSON:(NSMutableDictionary *)json fromLinkParams:(BranchOpenRequestLinkParams *) linkParams{
309309
json[BRANCH_REQUEST_KEY_DEBUG] = @(self.preferenceHelper.isDebug);
310310
[self safeSetValue:self.preferenceHelper.initialReferrer forKey:BRANCH_REQUEST_KEY_INITIAL_REFERRER onDict:json];
311311

312-
[self safeSetValue:openRequest.linkParams.linkClickIdentifier forKey:BRANCH_REQUEST_KEY_LINK_IDENTIFIER onDict:json];
313-
[self safeSetValue:openRequest.linkParams.spotlightIdentifier forKey:BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER onDict:json];
312+
[self safeSetValue:linkParams.linkClickIdentifier forKey:BRANCH_REQUEST_KEY_LINK_IDENTIFIER onDict:json];
313+
[self safeSetValue:linkParams.spotlightIdentifier forKey:BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER onDict:json];
314314

315315
}
316316

Sources/BranchSDK/Branch.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,12 +2089,11 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS
20892089
req = [[BranchInstallRequest alloc] initWithCallback:initSessionCallback];
20902090
}
20912091
req.callback = initSessionCallback;
2092-
req.urlString = params.referringURL;
20932092
req.linkParams = params;
20942093

20952094
[self.requestQueue insert:req at:0];
20962095

2097-
NSString *message = [NSString stringWithFormat:@"Request %@ callback %@ link %@", req, req.callback, req.urlString];
2096+
NSString *message = [NSString stringWithFormat:@"Request %@ callback %@ link params %@", req, req.callback, req.linkParams];
20982097
[[BranchLogger shared] logDebug:message error:nil];
20992098

21002099
} else {
@@ -2103,14 +2102,13 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS
21032102
if (params.referringURL) {
21042103
req = [[BranchOpenRequest alloc] initWithCallback:initSessionCallback];
21052104
req.callback = initSessionCallback;
2106-
req.urlString = params.referringURL;
21072105
req.linkParams = params;
21082106

21092107
// put it behind the one that's already on queue
21102108
[self.requestQueue insert:req at:1];
21112109

21122110
[[BranchLogger shared] logDebug:@"Link resolution request" error:nil];
2113-
NSString *message = [NSString stringWithFormat:@"Request %@ callback %@ link %@", req, req.callback, req.urlString];
2111+
NSString *message = [NSString stringWithFormat:@"Request %@ callback %@ link params%@", req, req.callback, req.linkParams];
21142112
[[BranchLogger shared] logDebug:message error:nil];
21152113
}
21162114
}

Sources/BranchSDK/BranchInstallRequest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ - (id)initWithCallback:(callbackWithStatus)callback {
2020

2121
- (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback {
2222
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:key UUID:self.requestUUID TimeStamp:self.requestCreationTimeStamp];
23-
NSDictionary *params = [factory dataForInstallWithRequestObject:self];
23+
NSDictionary *params = [factory dataForInstallWithLinkParams:self.linkParams];
2424

2525
[serverInterface postRequest:params url:[[BNCServerAPI sharedInstance] installServiceURL] key:key callback:callback];
2626
}

Sources/BranchSDK/BranchOpenRequest.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ - (id)initWithCallback:(callbackWithStatus)callback isInstall:(BOOL)isInstall {
4747

4848
- (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback {
4949
BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:key UUID:self.requestUUID TimeStamp:self.requestCreationTimeStamp];
50-
NSDictionary *params = [factory dataForOpenWithRequestObject:self];
50+
NSDictionary *params = [factory dataForOpenWithLinkParams:self.linkParams];
5151

5252
[serverInterface postRequest:params
5353
url:[[BNCServerAPI sharedInstance] openServiceURL]
@@ -140,8 +140,8 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error {
140140
}
141141

142142
NSString *referringURL = nil;
143-
if (self.urlString.length > 0) {
144-
referringURL = self.urlString;
143+
if (self.linkParams.referringURL.length > 0) {
144+
referringURL = self.linkParams.referringURL;
145145
} else {
146146
NSDictionary *sessionDataDict = [BNCEncodingUtils decodeJsonStringToDictionary:sessionData];
147147
NSString *link = sessionDataDict[BRANCH_RESPONSE_KEY_BRANCH_REFERRING_LINK];
@@ -249,13 +249,13 @@ - (NSString *)getActionName {
249249
- (instancetype)initWithCoder:(NSCoder *)decoder {
250250
self = [super initWithCoder:decoder];
251251
if (!self) return self;
252-
self.urlString = [decoder decodeObjectOfClass:NSString.class forKey:@"urlString"];
252+
self.linkParams.referringURL = [decoder decodeObjectOfClass:NSString.class forKey:@"urlString"];
253253
return self;
254254
}
255255

256256
- (void)encodeWithCoder:(NSCoder *)coder {
257257
[super encodeWithCoder:coder];
258-
[coder encodeObject:self.urlString forKey:@"urlString"];
258+
[coder encodeObject:self.linkParams.referringURL forKey:@"urlString"];
259259
}
260260

261261
+ (BOOL)supportsSecureCoding {

Sources/BranchSDK/Private/BNCRequestFactory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
2525
- (instancetype)initWithBranchKey:(NSString *)key UUID:(NSString *)requestUUID TimeStamp:(NSNumber *)requestTimeStamp NS_DESIGNATED_INITIALIZER;
2626
- (instancetype)init NS_UNAVAILABLE;
2727

28-
- (NSDictionary *)dataForInstallWithRequestObject:(BranchInstallRequest *) installRequest;
29-
- (NSDictionary *)dataForOpenWithRequestObject:(BranchOpenRequest *) openRequest;
28+
- (NSDictionary *)dataForInstallWithLinkParams:(BranchOpenRequestLinkParams *) linkParams;
29+
- (NSDictionary *)dataForOpenWithLinkParams:(BranchOpenRequestLinkParams *) linkParams;
3030

3131
// Event data is passed in
3232
- (NSDictionary *)dataForEventWithEventDictionary:(NSMutableDictionary *)dictionary;

Sources/BranchSDK/Private/BranchOpenRequest.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
@interface BranchOpenRequestLinkParams : NSObject
1313
@property (copy, nonatomic) NSString *linkClickIdentifier;
1414
@property (copy, nonatomic) NSString *spotlightIdentifier;
15-
@property (copy, nonatomic) NSString *referringURL;
15+
@property (copy, nonatomic) NSString *referringURL; // URL that triggered this install or open event
1616
@property (assign, nonatomic) BOOL dropURLOpen;
1717
@end
1818

1919
@interface BranchOpenRequest : BNCServerRequest
2020

21-
// URL that triggered this install or open event
22-
@property (nonatomic, copy, readwrite) NSString *urlString;
21+
2322
@property (nonatomic, copy) callbackWithStatus callback;
2423
@property (nonatomic, copy, readwrite) BranchOpenRequestLinkParams *linkParams;
2524

0 commit comments

Comments
 (0)