Skip to content

Commit 12a25c4

Browse files
authored
Merge pull request #412 from BranchMetrics/add-campaign
Add campaign to link properties
2 parents f59b00e + f0f5047 commit 12a25c4

17 files changed

+165
-61
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: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,20 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
199199
*/
200200
+ (BranchActivityItemProvider *)getBranchActivityItemWithParams:(NSDictionary *)params feature:(NSString *)feature stage:(NSString *)stage tags:(NSArray *)tags alias:(NSString *)alias;
201201

202+
/**
203+
Create a BranchActivityItemProvider which subclasses the `UIActivityItemProvider` This can be used for simple sharing via a `UIActivityViewController`.
204+
205+
Internally, this will create a short Branch Url that will be attached to the shared content.
206+
207+
@param params A dictionary to use while building up the Branch link.
208+
@param feature The feature the generated link will be associated with.
209+
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
210+
@param campaign Use this field to organize the links by actual marketing campaign.
211+
@param alias The alias for a link.
212+
@warning This can fail if the alias is already taken.
213+
*/
214+
+ (BranchActivityItemProvider *)getBranchActivityItemWithParams:(NSDictionary *)params feature:(NSString *)feature stage:(NSString *)stage campaign:(NSString *)campmaign tags:(NSArray *)tags alias:(NSString *)alias;
215+
202216
/**
203217
Create a BranchActivityItemProvider which subclasses the `UIActivityItemProvider` This can be used for simple sharing via a `UIActivityViewController`.
204218
@@ -759,21 +773,22 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
759773
- (NSString *)getShortURLWithParams:(NSDictionary *)params andTags:(NSArray *)tags andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andAlias:(NSString *)alias ignoreUAString:(NSString *)ignoreUAString;
760774

761775
/**
762-
Get a short url with specified tags, params, channel, feature, and stage. The usage type will default to unlimited.
776+
Get a short url with specified tags, params, channel, feature, stage and campaign. The usage type will default to unlimited.
763777
764778
@param params Dictionary of parameters to include in the link.
765779
@param tags An array of tags to associate with this link, useful for tracking.
766780
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
767781
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
768782
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
783+
@param campaign Use this field to organize the links by actual marketing campaign.
769784
@param alias The alias for a link.
770785
@param ignoreUAString The User Agent string to tell the server to ignore the next request from, to prevent it from treating a preview scrape as a link click.
771786
@param forceLinkCreation Whether we should create a link from the Branch Key even if initSession failed. Defaults to NO.
772787
@warning This method makes a synchronous url request.
773788
@warning This method is primarily intended to be an internal Branch method, used to work around a bug with SLComposeViewController
774789
@warning This can fail if the alias is already taken.
775790
*/
776-
- (NSString *)getShortURLWithParams:(NSDictionary *)params andTags:(NSArray *)tags andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andAlias:(NSString *)alias ignoreUAString:(NSString *)ignoreUAString forceLinkCreation:(BOOL)forceLinkCreation;
791+
- (NSString *)getShortURLWithParams:(NSDictionary *)params andTags:(NSArray *)tags andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andCampaign:(NSString *)campaign andAlias:(NSString *)alias ignoreUAString:(NSString *)ignoreUAString forceLinkCreation:(BOOL)forceLinkCreation;
777792

778793
/**
779794
Get a short url with specified tags, params, channel, feature, stage, and type.
@@ -816,6 +831,22 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
816831
*/
817832
- (NSString *)getShortUrlWithParams:(NSDictionary *)params andTags:(NSArray *)tags andAlias:(NSString *)alias andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andMatchDuration:(NSUInteger)duration;
818833

834+
835+
/**
836+
Get a short url with specified params, channel, feature, stage, campaign and match duration. The usage type will default to unlimited.
837+
838+
@param params Dictionary of parameters to include in the link.
839+
@param tags An array of tags to associate with this link, useful for tracking.
840+
@param alias The alias for a link.
841+
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
842+
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
843+
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
844+
@param campaign Use this field to organize the links by actual marketing campaign.
845+
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
846+
@warning This method makes a synchronous url request.
847+
*/
848+
- (NSString *)getShortUrlWithParams:(NSDictionary *)params andTags:(NSArray *)tags andAlias:(NSString *)alias andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andCampaign:campaign andMatchDuration:(NSUInteger)duration;
849+
819850
#pragma mark - Long Url generation
820851

821852
///--------------------------
@@ -1026,6 +1057,22 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
10261057
*/
10271058
- (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;
10281059

1060+
/**
1061+
Get a short url with the specified params, tags, channel, feature, stage, campaign and match duration. The usage type will default to unlimited.
1062+
1063+
@param params Dictionary of parameters to include in the link.
1064+
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
1065+
@param tags An array of tags to associate with this link, useful for tracking.
1066+
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
1067+
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
1068+
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
1069+
@param campaign Use this field to organize the links by actual marketing campaign.
1070+
@param callback Callback called with the url.
1071+
@param alias The alias for a link.
1072+
@warning This can fail if the alias is already taken.
1073+
*/
1074+
- (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;
1075+
10291076
- (void)getSpotlightUrlWithParams:(NSDictionary *)params callback:(callbackWithParams)callback;
10301077

10311078
#pragma mark - Content Discovery methods

0 commit comments

Comments
 (0)