Skip to content

Commit 83e8bc5

Browse files
authored
Fix duplicate URL when sharing to clipboard (AIS-369,GH-#726).
1 parent 93d2af9 commit 83e8bc5

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

Branch-SDK/Branch-SDK/BranchActivityItemProvider.m

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,30 @@ - (id)initWithParams:(NSDictionary *)params andTags:(NSArray *)tags andFeature:(
3333

3434
- (id)initWithParams:(NSDictionary *)params tags:(NSArray *)tags feature:(NSString *)feature stage:(NSString *)stage campaign:(NSString *)campaign alias:(NSString *)alias delegate:(id <BranchActivityItemProviderDelegate>)delegate {
3535
NSString *url = [[Branch getInstance] getLongURLWithParams:params andChannel:nil andTags:tags andFeature:feature andStage:stage andAlias:alias];
36-
37-
if ((self = [super initWithPlaceholderItem:[NSURL URLWithString:url]])) {
38-
_params = params;
39-
_tags = tags;
40-
_feature = feature;
41-
_stage = stage;
42-
_campaign = campaign;
43-
_alias = alias;
44-
_userAgentString = [BNCDeviceInfo userAgentString];
45-
_delegate = delegate;
36+
37+
if ([UIDevice currentDevice].systemVersion.doubleValue < 11.0) {
38+
if ((self = [super initWithPlaceholderItem:[NSURL URLWithString:url]])) {
39+
_params = params;
40+
_tags = tags;
41+
_feature = feature;
42+
_stage = stage;
43+
_campaign = campaign;
44+
_alias = alias;
45+
_userAgentString = [BNCDeviceInfo userAgentString];
46+
_delegate = delegate;
47+
}
48+
} else {
49+
if ((self = [super initWithPlaceholderItem:url])) {
50+
_params = params;
51+
_tags = tags;
52+
_feature = feature;
53+
_stage = stage;
54+
_campaign = campaign;
55+
_alias = alias;
56+
_userAgentString = [BNCDeviceInfo userAgentString];
57+
_delegate = delegate;
58+
}
4659
}
47-
4860
return self;
4961
}
5062

@@ -68,8 +80,8 @@ - (id)item {
6880
// existing list, telling the backend to ignore the first click
6981
NSArray *scrapers = @[@"Facebook", @"Twitter", @"Slack", @"Apple Notes"];
7082
for (NSString *scraper in scrapers) {
71-
if ([channel isEqualToString:scraper])
72-
return [NSURL URLWithString:[[Branch getInstance]
83+
if ([channel isEqualToString:scraper]) {
84+
NSURL *URL = [NSURL URLWithString:[[Branch getInstance]
7385
getShortURLWithParams:params
7486
andTags:tags
7587
andChannel:channel
@@ -79,6 +91,8 @@ - (id)item {
7991
andAlias:alias
8092
ignoreUAString:self.userAgentString
8193
forceLinkCreation:YES]];
94+
return ([UIDevice currentDevice].systemVersion.doubleValue < 11.0) ? URL : URL.absoluteString;
95+
}
8296
}
8397

8498
// Wrap the link in HTML content
@@ -109,17 +123,18 @@ - (id)item {
109123
[params objectForKey:BRANCH_LINK_DATA_KEY_EMAIL_HTML_FOOTER]];
110124
}
111125

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]];
122-
126+
NSURL *URL =
127+
[NSURL URLWithString:[[Branch getInstance]
128+
getShortURLWithParams:params
129+
andTags:tags
130+
andChannel:channel
131+
andFeature:feature
132+
andStage:stage
133+
andCampaign:campaign
134+
andAlias:alias
135+
ignoreUAString:nil
136+
forceLinkCreation:YES]];
137+
return ([UIDevice currentDevice].systemVersion.doubleValue < 11.0) ? URL : URL.absoluteString;
123138
}
124139

125140
#pragma mark - Internals

Branch-SDK/Branch-SDK/BranchShareLink.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ - (void) shareDidComplete:(BOOL)completed activityError:(NSError*)error {
128128
andStage:self.linkProperties.stage
129129
andAlias:self.linkProperties.alias];
130130
self.shareURL = [[NSURL alloc] initWithString:URLString];
131-
item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareURL];
131+
if ([UIDevice currentDevice].systemVersion.doubleValue < 11.0)
132+
item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareURL];
133+
else
134+
item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareURL.absoluteString];
132135
item.itemType = BranchShareActivityItemTypeBranchURL;
133136
item.parent = self;
134137
[items addObject:item];
@@ -258,7 +261,7 @@ - (id) shareObjectForItem:(BranchShareActivityItem*)activityItem
258261
ignoreUAString:userAgentString
259262
forceLinkCreation:YES];
260263
self.shareURL = [NSURL URLWithString:URLString];
261-
return self.shareURL;
264+
return ([UIDevice currentDevice].systemVersion.doubleValue < 11.0) ? self.shareURL :self.shareURL.absoluteString;
262265
}
263266

264267
@end

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Branch iOS SDK Change Log
22

33
- v0.19.0
4+
* Fixed duplicate URL being copied when a link is copied to the clipboard in iOS 11.
45
* Changed the use of `typeof` to `__typeof`, for stricter compiler options.
56
* The SDK now send the Apple Search Ad attribution only when it changes (DLA-969, #723).
67
* Add local ip address to returned device info (AIS-341).

0 commit comments

Comments
 (0)