diff --git a/Sources/BranchSDK/BNCRequestFactory.m b/Sources/BranchSDK/BNCRequestFactory.m index 9940afa3a..7d62a4692 100644 --- a/Sources/BranchSDK/BNCRequestFactory.m +++ b/Sources/BranchSDK/BNCRequestFactory.m @@ -82,7 +82,7 @@ - (BOOL)isTrackingDisabled { return Branch.trackingDisabled; } -- (NSDictionary *)dataForInstallWithRequestObject:(BranchInstallRequest *) installRequest { +- (NSDictionary *)dataForInstallWithLinkParams:(BranchOpenRequestLinkParams *) linkParams { NSMutableDictionary *json = [NSMutableDictionary new]; // All requests @@ -101,18 +101,18 @@ - (NSDictionary *)dataForInstallWithRequestObject:(BranchInstallRequest *) insta // Install and Open [self addDeveloperUserIDToJSON:json]; [self addSystemObserverDataToJSON:json]; - [self addOpenRequestDataToJSON:json fromRequestObject:installRequest]; + [self addOpenRequestDataToJSON:json fromLinkParams:linkParams]; [self addPartnerParametersToJSON:json]; [self addAppleReceiptSourceToJSON:json]; [self addTimestampsToJSON:json]; // Check if the urlString is a valid URL to ensure it's a universal link, not the external intent uri - if (installRequest.urlString && !installRequest.linkParams.dropURLOpen) { - NSURL *url = [NSURL URLWithString:installRequest.urlString]; + if (linkParams.referringURL && !linkParams.dropURLOpen) { + NSURL *url = [NSURL URLWithString:linkParams.referringURL]; if (url && ([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"])) { - [self safeSetValue:installRequest.urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json]; + [self safeSetValue:linkParams.referringURL forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json]; } else { - [self safeSetValue:installRequest.urlString forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json]; + [self safeSetValue:linkParams.referringURL forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json]; } } @@ -134,7 +134,7 @@ - (NSDictionary *)dataForInstallWithRequestObject:(BranchInstallRequest *) insta return json; } -- (NSDictionary *)dataForOpenWithRequestObject:(BranchOpenRequest *) openRequest { +- (NSDictionary *)dataForOpenWithLinkParams:(BranchOpenRequestLinkParams *) linkParams{ NSMutableDictionary *json = [NSMutableDictionary new]; // All requests @@ -156,19 +156,19 @@ - (NSDictionary *)dataForOpenWithRequestObject:(BranchOpenRequest *) openRequest // Install and Open [self addDeveloperUserIDToJSON:json]; [self addSystemObserverDataToJSON:json]; - [self addOpenRequestDataToJSON:json fromRequestObject:openRequest]; + [self addOpenRequestDataToJSON:json fromLinkParams:linkParams]; [self addPartnerParametersToJSON:json]; [self addAppleReceiptSourceToJSON:json]; [self addTimestampsToJSON:json]; // Check if the urlString is a valid URL to ensure it's a universal link, not the external intent uri - if (openRequest.urlString && !openRequest.linkParams.dropURLOpen) { - NSURL *url = [NSURL URLWithString:openRequest.urlString]; + if (linkParams.referringURL && !linkParams.dropURLOpen) { + NSURL *url = [NSURL URLWithString:linkParams.referringURL]; if (url && ([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"])) { - [self safeSetValue:openRequest.urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json]; + [self safeSetValue:linkParams.referringURL forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json]; } else { - [self safeSetValue:openRequest.urlString forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json]; + [self safeSetValue:linkParams.referringURL forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json]; } } @@ -305,12 +305,12 @@ - (void)addShortURLTokensToJSON:(NSMutableDictionary *)json isSpotlightRequest:( json[BRANCH_REQUEST_KEY_SESSION_ID] = self.preferenceHelper.sessionID; } -- (void)addOpenRequestDataToJSON:(NSMutableDictionary *)json fromRequestObject:(BranchOpenRequest *) openRequest{ +- (void)addOpenRequestDataToJSON:(NSMutableDictionary *)json fromLinkParams:(BranchOpenRequestLinkParams *) linkParams{ json[BRANCH_REQUEST_KEY_DEBUG] = @(self.preferenceHelper.isDebug); [self safeSetValue:self.preferenceHelper.initialReferrer forKey:BRANCH_REQUEST_KEY_INITIAL_REFERRER onDict:json]; - [self safeSetValue:openRequest.linkParams.linkClickIdentifier forKey:BRANCH_REQUEST_KEY_LINK_IDENTIFIER onDict:json]; - [self safeSetValue:openRequest.linkParams.spotlightIdentifier forKey:BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER onDict:json]; + [self safeSetValue:linkParams.linkClickIdentifier forKey:BRANCH_REQUEST_KEY_LINK_IDENTIFIER onDict:json]; + [self safeSetValue:linkParams.spotlightIdentifier forKey:BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER onDict:json]; } diff --git a/Sources/BranchSDK/Branch.m b/Sources/BranchSDK/Branch.m index 7e12500b0..236cde5d5 100644 --- a/Sources/BranchSDK/Branch.m +++ b/Sources/BranchSDK/Branch.m @@ -2089,12 +2089,11 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS req = [[BranchInstallRequest alloc] initWithCallback:initSessionCallback]; } req.callback = initSessionCallback; - req.urlString = params.referringURL; req.linkParams = params; [self.requestQueue insert:req at:0]; - NSString *message = [NSString stringWithFormat:@"Request %@ callback %@ link %@", req, req.callback, req.urlString]; + NSString *message = [NSString stringWithFormat:@"Request %@ callback %@ link params %@", req, req.callback, req.linkParams]; [[BranchLogger shared] logDebug:message error:nil]; } else { @@ -2103,14 +2102,13 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS if (params.referringURL) { req = [[BranchOpenRequest alloc] initWithCallback:initSessionCallback]; req.callback = initSessionCallback; - req.urlString = params.referringURL; req.linkParams = params; // put it behind the one that's already on queue [self.requestQueue insert:req at:1]; [[BranchLogger shared] logDebug:@"Link resolution request" error:nil]; - NSString *message = [NSString stringWithFormat:@"Request %@ callback %@ link %@", req, req.callback, req.urlString]; + NSString *message = [NSString stringWithFormat:@"Request %@ callback %@ link params%@", req, req.callback, req.linkParams]; [[BranchLogger shared] logDebug:message error:nil]; } } diff --git a/Sources/BranchSDK/BranchInstallRequest.m b/Sources/BranchSDK/BranchInstallRequest.m index b28c18b54..6f7ebabbe 100644 --- a/Sources/BranchSDK/BranchInstallRequest.m +++ b/Sources/BranchSDK/BranchInstallRequest.m @@ -20,7 +20,7 @@ - (id)initWithCallback:(callbackWithStatus)callback { - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback { BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:key UUID:self.requestUUID TimeStamp:self.requestCreationTimeStamp]; - NSDictionary *params = [factory dataForInstallWithRequestObject:self]; + NSDictionary *params = [factory dataForInstallWithLinkParams:self.linkParams]; [serverInterface postRequest:params url:[[BNCServerAPI sharedInstance] installServiceURL] key:key callback:callback]; } diff --git a/Sources/BranchSDK/BranchOpenRequest.m b/Sources/BranchSDK/BranchOpenRequest.m index a1707b98d..9d68810bd 100644 --- a/Sources/BranchSDK/BranchOpenRequest.m +++ b/Sources/BranchSDK/BranchOpenRequest.m @@ -47,7 +47,7 @@ - (id)initWithCallback:(callbackWithStatus)callback isInstall:(BOOL)isInstall { - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback { BNCRequestFactory *factory = [[BNCRequestFactory alloc] initWithBranchKey:key UUID:self.requestUUID TimeStamp:self.requestCreationTimeStamp]; - NSDictionary *params = [factory dataForOpenWithRequestObject:self]; + NSDictionary *params = [factory dataForOpenWithLinkParams:self.linkParams]; [serverInterface postRequest:params url:[[BNCServerAPI sharedInstance] openServiceURL] @@ -140,8 +140,8 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error { } NSString *referringURL = nil; - if (self.urlString.length > 0) { - referringURL = self.urlString; + if (self.linkParams.referringURL.length > 0) { + referringURL = self.linkParams.referringURL; } else { NSDictionary *sessionDataDict = [BNCEncodingUtils decodeJsonStringToDictionary:sessionData]; NSString *link = sessionDataDict[BRANCH_RESPONSE_KEY_BRANCH_REFERRING_LINK]; @@ -249,13 +249,13 @@ - (NSString *)getActionName { - (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) return self; - self.urlString = [decoder decodeObjectOfClass:NSString.class forKey:@"urlString"]; + self.linkParams.referringURL = [decoder decodeObjectOfClass:NSString.class forKey:@"urlString"]; return self; } - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; - [coder encodeObject:self.urlString forKey:@"urlString"]; + [coder encodeObject:self.linkParams.referringURL forKey:@"urlString"]; } + (BOOL)supportsSecureCoding { diff --git a/Sources/BranchSDK/Private/BNCRequestFactory.h b/Sources/BranchSDK/Private/BNCRequestFactory.h index 1d89527a4..403f831bd 100644 --- a/Sources/BranchSDK/Private/BNCRequestFactory.h +++ b/Sources/BranchSDK/Private/BNCRequestFactory.h @@ -25,8 +25,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithBranchKey:(NSString *)key UUID:(NSString *)requestUUID TimeStamp:(NSNumber *)requestTimeStamp NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; -- (NSDictionary *)dataForInstallWithRequestObject:(BranchInstallRequest *) installRequest; -- (NSDictionary *)dataForOpenWithRequestObject:(BranchOpenRequest *) openRequest; +- (NSDictionary *)dataForInstallWithLinkParams:(BranchOpenRequestLinkParams *) linkParams; +- (NSDictionary *)dataForOpenWithLinkParams:(BranchOpenRequestLinkParams *) linkParams; // Event data is passed in - (NSDictionary *)dataForEventWithEventDictionary:(NSMutableDictionary *)dictionary; diff --git a/Sources/BranchSDK/Private/BranchOpenRequest.h b/Sources/BranchSDK/Private/BranchOpenRequest.h index e7fba3c17..a5e414afb 100644 --- a/Sources/BranchSDK/Private/BranchOpenRequest.h +++ b/Sources/BranchSDK/Private/BranchOpenRequest.h @@ -12,14 +12,13 @@ @interface BranchOpenRequestLinkParams : NSObject @property (copy, nonatomic) NSString *linkClickIdentifier; @property (copy, nonatomic) NSString *spotlightIdentifier; -@property (copy, nonatomic) NSString *referringURL; +@property (copy, nonatomic) NSString *referringURL; // URL that triggered this install or open event @property (assign, nonatomic) BOOL dropURLOpen; @end @interface BranchOpenRequest : BNCServerRequest -// URL that triggered this install or open event -@property (nonatomic, copy, readwrite) NSString *urlString; + @property (nonatomic, copy) callbackWithStatus callback; @property (nonatomic, copy, readwrite) BranchOpenRequestLinkParams *linkParams;