|
8 | 8 |
|
9 | 9 | #import "BranchActivityItemProvider.h" |
10 | 10 | #import "Branch.h" |
| 11 | +#import "BranchConstants.h" |
11 | 12 | #import "BNCSystemObserver.h" |
12 | 13 | #import "BNCDeviceInfo.h" |
13 | 14 |
|
@@ -57,19 +58,67 @@ - (id)item { |
57 | 58 | NSString *stage = [self stageForChannel:channel]; |
58 | 59 | NSString *campaign = [self campaignForChannel:channel]; |
59 | 60 | NSString *alias = [self aliasForChannel:channel]; |
60 | | - |
| 61 | + |
61 | 62 | // Allow the channel param to be overridden, perhaps they want "fb" instead of "facebook" |
62 | 63 | if ([self.delegate respondsToSelector:@selector(activityItemOverrideChannelForChannel:)]) { |
63 | 64 | channel = [self.delegate activityItemOverrideChannelForChannel:channel]; |
64 | 65 | } |
65 | 66 |
|
66 | | - // Because Facebook et al immediately scrape URLs, we add an additional parameter to the existing list, telling the backend to ignore the first click |
| 67 | + // Because Facebook et al immediately scrape URLs, we add an additional parameter to the |
| 68 | + // existing list, telling the backend to ignore the first click |
67 | 69 | NSArray *scrapers = @[@"Facebook", @"Twitter", @"Slack", @"Apple Notes"]; |
68 | 70 | for (NSString *scraper in scrapers) { |
69 | 71 | if ([channel isEqualToString:scraper]) |
70 | | - return [NSURL URLWithString:[[Branch getInstance] getShortURLWithParams:params andTags:tags andChannel:channel andFeature:feature andStage:stage andCampaign:campaign andAlias:alias ignoreUAString:self.userAgentString forceLinkCreation:YES]]; |
| 72 | + return [NSURL URLWithString:[[Branch getInstance] |
| 73 | + getShortURLWithParams:params |
| 74 | + andTags:tags |
| 75 | + andChannel:channel |
| 76 | + andFeature:feature |
| 77 | + andStage:stage |
| 78 | + andCampaign:campaign |
| 79 | + andAlias:alias |
| 80 | + ignoreUAString:self.userAgentString |
| 81 | + forceLinkCreation:YES]]; |
71 | 82 | } |
72 | | - return [NSURL URLWithString:[[Branch getInstance] getShortURLWithParams:params andTags:tags andChannel:channel andFeature:feature andStage:stage andCampaign:campaign andAlias:alias ignoreUAString:nil forceLinkCreation:YES]]; |
| 83 | + |
| 84 | + // Wrap the link in HTML content |
| 85 | + if (self.activityType == UIActivityTypeMail && |
| 86 | + [params objectForKey:BRANCH_LINK_DATA_KEY_EMAIL_HTML_HEADER] && |
| 87 | + [params objectForKey:BRANCH_LINK_DATA_KEY_EMAIL_HTML_FOOTER]) { |
| 88 | + NSURL *link = [NSURL URLWithString:[[Branch getInstance] |
| 89 | + getShortURLWithParams:params |
| 90 | + andTags:tags |
| 91 | + andChannel:channel |
| 92 | + andFeature:feature |
| 93 | + andStage:stage |
| 94 | + andCampaign:campaign |
| 95 | + andAlias:alias |
| 96 | + ignoreUAString:nil |
| 97 | + forceLinkCreation:YES]]; |
| 98 | + NSString *emailLink; |
| 99 | + if ([params objectForKey:BRANCH_LINK_DATA_KEY_EMAIL_HTML_LINK_TEXT]) { |
| 100 | + emailLink = [NSString stringWithFormat:@"<a href=\"%@\">%@</a>", |
| 101 | + link, [params objectForKey:BRANCH_LINK_DATA_KEY_EMAIL_HTML_LINK_TEXT]]; |
| 102 | + } else { |
| 103 | + emailLink = link.absoluteString; |
| 104 | + } |
| 105 | + |
| 106 | + return [NSString stringWithFormat:@"<html>%@%@%@</html>", |
| 107 | + [params objectForKey:BRANCH_LINK_DATA_KEY_EMAIL_HTML_HEADER], |
| 108 | + emailLink, |
| 109 | + [params objectForKey:BRANCH_LINK_DATA_KEY_EMAIL_HTML_FOOTER]]; |
| 110 | + } |
| 111 | + |
| 112 | + return [NSURL URLWithString:[[Branch getInstance] |
| 113 | + getShortURLWithParams:params |
| 114 | + andTags:tags |
| 115 | + andChannel:channel |
| 116 | + andFeature:feature |
| 117 | + andStage:stage |
| 118 | + andCampaign:campaign |
| 119 | + andAlias:alias |
| 120 | + ignoreUAString:nil |
| 121 | + forceLinkCreation:YES]]; |
73 | 122 |
|
74 | 123 | } |
75 | 124 |
|
|
0 commit comments