Skip to content

Commit 2fc8174

Browse files
authored
Merge pull request #993 from BranchMetrics/INTENG-8456-sharesheet-option2
INTENG-8456 allow overriding the placeholder url
2 parents 5b163b2 + 06f7b49 commit 2fc8174

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

Branch-SDK/Branch-SDK/BranchShareLink.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ Presents a UIActivityViewController that shares the Branch link.
8686
///The title for the share sheet.
8787
@property (nonatomic, strong) NSString*_Nullable title;
8888

89-
///Share text for the item.
89+
// Override the default placeholder URL
90+
// iOS 13+ fetches a preview header icon, text and domain name from this URL.
91+
// By default, we use the Branch bnc.lt link, but if you wish more control override it here.
92+
@property (nonatomic, strong, nullable) NSURL *placeholderURL;
93+
94+
///Share text for the item. This is not the text in the iOS 13+ preview header.
9095
///This text can be changed later when the `branchShareSheetWillShare:` delegate method is called.
9196
@property (nonatomic, strong) NSString*_Nullable shareText;
9297

Branch-SDK/Branch-SDK/BranchShareLink.m

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,29 @@ - (void) shareDidComplete:(BOOL)completed activityError:(NSError*)error {
134134
[_activityItems addObject:item];
135135
}
136136

137-
NSString *URLString =
138-
[[Branch getInstance]
139-
getLongURLWithParams:self.serverParameters
140-
andChannel:self.linkProperties.channel
141-
andTags:self.linkProperties.tags
142-
andFeature:self.linkProperties.feature
143-
andStage:self.linkProperties.stage
144-
andAlias:self.linkProperties.alias];
145-
self.shareURL = [[NSURL alloc] initWithString:URLString];
146-
if (self.returnURL)
137+
if (self.placeholderURL) {
138+
// use user provided placeholder url
139+
self.shareURL = self.placeholderURL;
140+
} else {
141+
142+
// use long link as the placeholder url
143+
NSString *URLString =
144+
[[Branch getInstance]
145+
getLongURLWithParams:self.serverParameters
146+
andChannel:self.linkProperties.channel
147+
andTags:self.linkProperties.tags
148+
andFeature:self.linkProperties.feature
149+
andStage:self.linkProperties.stage
150+
andAlias:self.linkProperties.alias];
151+
self.shareURL = [[NSURL alloc] initWithString:URLString];
152+
}
153+
154+
if (self.returnURL) {
147155
item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareURL];
148-
else
156+
} else {
149157
item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareURL.absoluteString];
158+
}
159+
150160
item.itemType = BranchShareActivityItemTypeBranchURL;
151161
item.parent = self;
152162
[_activityItems addObject:item];

Branch-TestBed/Branch-TestBed/AppDelegate.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ - (BOOL)application:(UIApplication *)application
3232

3333

3434
// test pre init support
35-
// [self testDispatchToIsolationQueue:branch]
35+
//[self testDispatchToIsolationQueue:branch]
3636

3737
// Comment out (for match guarantee testing) / or un-comment to toggle debugging:
3838
// Note: Unit tests will fail if 'setDebug' is set.
@@ -42,7 +42,7 @@ - (BOOL)application:(UIApplication *)application
4242
//[branch validateSDKIntegration];
4343

4444
// Check for Apple Search Ad attribution (trade-off: slows down app startup):
45-
[branch delayInitToCheckForSearchAds];
45+
//[branch delayInitToCheckForSearchAds];
4646

4747
/*
4848
* Required: Initialize Branch, passing a deep link handler block:
@@ -61,10 +61,10 @@ - (BOOL)application:(UIApplication *)application
6161
return YES;
6262
}
6363

64-
// pre init support is meant for extensions, for exmaple, when Adobe axtension needs to pass in Adobe IDs
64+
// pre init support is meant for extensions, for example, when Adobe axtension needs to pass in Adobe IDs
6565
// before init session is called. This method will block the queue used by open/install requests until the
6666
// the passsed in block completes
67-
- (void) testDispatchToIsolationQueue:(Branch*)branch {
67+
- (void)testDispatchToIsolationQueue:(Branch *)branch {
6868
[branch dispatchToIsolationQueue:^{
6969
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
7070
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)),

0 commit comments

Comments
 (0)