Skip to content

Commit 1ea4965

Browse files
committed
add campaign to getShortURlRL methods
1 parent bf539d0 commit 1ea4965

File tree

10 files changed

+104
-39
lines changed

10 files changed

+104
-39
lines changed

Branch-SDK/Branch-SDK/BNCLinkData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef NS_ENUM(NSUInteger, BranchLinkType) {
2323
- (void)setupChannel:(NSString *)channel;
2424
- (void)setupFeature:(NSString *)feature;
2525
- (void)setupStage:(NSString *)stage;
26+
- (void)setupCampaign:(NSString *)campaign;
2627
- (void)setupParams:(NSDictionary *)params;
2728
- (void)setupMatchDuration:(NSUInteger)duration;
2829
- (void)setupIgnoreUAString:(NSString *)ignoreUAString;

Branch-SDK/Branch-SDK/BNCLinkData.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ @interface BNCLinkData ()
1717
@property (strong, nonatomic) NSString *channel;
1818
@property (strong, nonatomic) NSString *feature;
1919
@property (strong, nonatomic) NSString *stage;
20+
@property (strong, nonatomic) NSString *campaign;
2021
@property (strong, nonatomic) NSDictionary *params;
2122
@property (strong, nonatomic) NSString *ignoreUAString;
2223
@property (assign, nonatomic) BranchLinkType type;
@@ -90,6 +91,14 @@ - (void)setupStage:(NSString *)stage {
9091
}
9192
}
9293

94+
- (void)setupCampaign:(NSString *)campaign {
95+
if (campaign) {
96+
_campaign = campaign;
97+
98+
self.data[BRANCH_REQUEST_KEY_URL_CAMPAIGN] = campaign;
99+
}
100+
}
101+
93102
- (void)setupIgnoreUAString:(NSString *)ignoreUAString {
94103
if (ignoreUAString) {
95104
_ignoreUAString = ignoreUAString;
@@ -116,6 +125,7 @@ - (NSUInteger)hash {
116125
result = prime * result + [[BNCEncodingUtils md5Encode:self.channel] hash];
117126
result = prime * result + [[BNCEncodingUtils md5Encode:self.feature] hash];
118127
result = prime * result + [[BNCEncodingUtils md5Encode:self.stage] hash];
128+
result = prime * result + [[BNCEncodingUtils md5Encode:self.campaign] hash];
119129
result = prime * result + [[BNCEncodingUtils md5Encode:encodedParams] hash];
120130
result = prime * result + self.duration;
121131

@@ -145,6 +155,9 @@ - (void)encodeWithCoder:(NSCoder *)coder {
145155
if (self.stage) {
146156
[coder encodeObject:self.stage forKey:BRANCH_REQUEST_KEY_URL_STAGE];
147157
}
158+
if (self.campaign) {
159+
[coder encodeObject:self.campaign forKey:BRANCH_REQUEST_KEY_URL_CAMPAIGN];
160+
}
148161
if (self.params) {
149162
NSString *encodedParams = [BNCEncodingUtils encodeDictionaryToJsonString:self.params];
150163
[coder encodeObject:encodedParams forKey:BRANCH_REQUEST_KEY_URL_DATA];
@@ -162,6 +175,7 @@ - (id)initWithCoder:(NSCoder *)coder {
162175
self.channel = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_CHANNEL];
163176
self.feature = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_FEATURE];
164177
self.stage = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_STAGE];
178+
self.campaign = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_CAMPAIGN];
165179
self.duration = [[coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_DURATION] integerValue];
166180

167181
NSString *encodedParams = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_DATA];

Branch-SDK/Branch-SDK/Branch.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,22 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
816816
*/
817817
- (NSString *)getShortUrlWithParams:(NSDictionary *)params andTags:(NSArray *)tags andAlias:(NSString *)alias andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andMatchDuration:(NSUInteger)duration;
818818

819+
820+
/**
821+
Get a short url with specified params, channel, feature, stage, campaign and match duration. The usage type will default to unlimited.
822+
823+
@param params Dictionary of parameters to include in the link.
824+
@param tags An array of tags to associate with this link, useful for tracking.
825+
@param alias The alias for a link.
826+
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
827+
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
828+
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
829+
@param campaign Use this field to organize the links by actual marketing campaign.
830+
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
831+
@warning This method makes a synchronous url request.
832+
*/
833+
- (NSString *)getShortUrlWithParams:(NSDictionary *)params andTags:(NSArray *)tags andAlias:(NSString *)alias andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andCampaign:campaign andMatchDuration:(NSUInteger)duration;
834+
819835
#pragma mark - Long Url generation
820836

821837
///--------------------------
@@ -1026,6 +1042,22 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
10261042
*/
10271043
- (void)getShortUrlWithParams:(NSDictionary *)params andTags:(NSArray *)tags andAlias:(NSString *)alias andMatchDuration:(NSUInteger)duration andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andCallback:(callbackWithUrl)callback;
10281044

1045+
/**
1046+
Get a short url with the specified params, tags, channel, feature, stage, campaign and match duration. The usage type will default to unlimited.
1047+
1048+
@param params Dictionary of parameters to include in the link.
1049+
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
1050+
@param tags An array of tags to associate with this link, useful for tracking.
1051+
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
1052+
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
1053+
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
1054+
@param campaign Use this field to organize the links by actual marketing campaign.
1055+
@param callback Callback called with the url.
1056+
@param alias The alias for a link.
1057+
@warning This can fail if the alias is already taken.
1058+
*/
1059+
- (void)getShortUrlWithParams:(NSDictionary *)params andTags:(NSArray *)tags andAlias:(NSString *)alias andMatchDuration:(NSUInteger)duration andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andCampaign:(NSString *)campaign andCallback:(callbackWithUrl)callback;
1060+
10291061
- (void)getSpotlightUrlWithParams:(NSDictionary *)params callback:(callbackWithParams)callback;
10301062

10311063
#pragma mark - Content Discovery methods

0 commit comments

Comments
 (0)