Skip to content

Commit ecc19cc

Browse files
author
Edward Smith
committed
Merge branch 'staging' of ssh://github.com/BranchMetrics/ios-branch-deep-linking into QA
2 parents 3b23df1 + 4a53c6b commit ecc19cc

File tree

3 files changed

+42
-12
lines changed

3 files changed

+42
-12
lines changed

Branch-SDK/Branch-SDK/BranchShareLink.m

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ typedef NS_ENUM(NSInteger, BranchShareActivityItemType) {
2323
#pragma mark BranchShareLink
2424

2525
@interface BranchShareLink () {
26-
NSArray<UIActivityItemProvider*>* _activityItems;
26+
NSPointerArray* _activityItems;
2727
}
2828

2929
- (id) shareObjectForItem:(BranchShareActivityItem*)activityItem
@@ -36,7 +36,7 @@ - (id) shareObjectForItem:(BranchShareActivityItem*)activityItem
3636

3737
@interface BranchShareActivityItem : UIActivityItemProvider
3838
@property (nonatomic, assign) BranchShareActivityItemType itemType;
39-
@property (nonatomic, weak) BranchShareLink *parent;
39+
@property (nonatomic, strong) BranchShareLink *parent;
4040
@end
4141

4242
@implementation BranchShareActivityItem
@@ -85,10 +85,9 @@ - (void) shareDidComplete:(BOOL)completed activityError:(NSError*)error {
8585

8686
- (NSArray<UIActivityItemProvider*>*_Nonnull) activityItems {
8787
if (_activityItems) {
88-
return _activityItems;
88+
return [_activityItems allObjects];
8989
}
9090

91-
9291
// Make sure we can share
9392

9493
if (!(self.universalObject.canonicalIdentifier ||
@@ -111,12 +110,12 @@ - (void) shareDidComplete:(BOOL)completed activityError:(NSError*)error {
111110
[self.universalObject userCompletedAction:BNCShareInitiatedEvent];
112111

113112
BranchShareActivityItem *item = nil;
114-
NSMutableArray *items = [NSMutableArray new];
113+
_activityItems = [NSPointerArray weakObjectsPointerArray];
115114
if (self.shareText.length) {
116115
item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareText];
117116
item.itemType = BranchShareActivityItemTypeShareText;
118117
item.parent = self;
119-
[items addObject:item];
118+
[_activityItems addPointer:(__bridge void * _Nullable)(item)];
120119
}
121120

122121
NSString *URLString =
@@ -131,17 +130,16 @@ - (void) shareDidComplete:(BOOL)completed activityError:(NSError*)error {
131130
item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:URL];
132131
item.itemType = BranchShareActivityItemTypeBranchURL;
133132
item.parent = self;
134-
[items addObject:item];
133+
[_activityItems addPointer:(__bridge void * _Nullable)(item)];
135134

136135
if (self.shareObject) {
137136
item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareObject];
138137
item.itemType = BranchShareActivityItemTypeOther;
139138
item.parent = self;
140-
[items addObject:self.shareObject];
139+
[_activityItems addPointer:(__bridge void * _Nullable)(item)];
141140
}
142141

143-
_activityItems = items;
144-
return _activityItems;
142+
return [_activityItems allObjects];
145143
}
146144

147145
- (void) presentActivityViewControllerFromViewController:(UIViewController*_Nullable)viewController

Branch-TestBed-Swift/TestBed-Swift/Base.lproj/Main.storyboard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
<fontDescription key="fontDescription" type="system" pointSize="15"/>
273273
<state key="normal" title="Share Alias Branch Link"/>
274274
<connections>
275-
<action selector="shareAliasBranchLinkAction:" destination="3bi-5k-7qj" eventType="touchUpInside" id="9Zf-kF-7nj"/>
275+
<action selector="shareAliasActivityViewController:" destination="3bi-5k-7qj" eventType="touchUpInside" id="ibr-Hq-JNL"/>
276276
</connections>
277277
</button>
278278
</subviews>

Branch-TestBed-Swift/TestBed-Swift/ViewController.swift

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,46 @@ class ViewController: UITableViewController, BranchShareLinkDelegate {
261261
) {
262262
branchShareLink.title = "Share your alias link!"
263263
branchShareLink.delegate = self
264-
branchShareLink.shareText = "Shared from Branch's TestBed-Swift at \(self.dateFormatter().string(from: Date()))"
264+
branchShareLink.shareText =
265+
"Shared from Branch's TestBed-Swift at \(self.dateFormatter().string(from: Date()))"
265266
branchShareLink.presentActivityViewController(
266267
from: self,
267268
anchor: actionButton
268269
)
269270
}
270271
}
271272

273+
@IBAction func shareAliasActivityViewController(_ sender: AnyObject) {
274+
// Share an alias Branch link:
275+
276+
let alias = "Share-Alias-Link-Example"
277+
let canonicalIdentifier = alias
278+
279+
let shareBranchObject = BranchUniversalObject.init(canonicalIdentifier: canonicalIdentifier)
280+
shareBranchObject.title = "Share Branch Link Example"
281+
shareBranchObject.canonicalUrl = "https://developer.branch.io/"
282+
shareBranchObject.imageUrl = "https://branch.io/img/press/kit/badge-black.png"
283+
shareBranchObject.keywords = [ "example", "short", "share", "link" ]
284+
shareBranchObject.contentDescription = "This is an example shared alias link."
285+
shareBranchObject.addMetadataKey("publicSlug", value: canonicalIdentifier)
286+
287+
let shareLinkProperties = BranchLinkProperties()
288+
shareLinkProperties.alias = alias
289+
shareLinkProperties.controlParams = ["$fallback_url": "https://support.branch.io/support/home"]
290+
291+
if let branchShareLink = BranchShareLink.init(
292+
universalObject: shareBranchObject,
293+
linkProperties: shareLinkProperties
294+
) {
295+
branchShareLink.delegate = self
296+
let activityViewController = UIActivityViewController.init(
297+
activityItems: branchShareLink.activityItems(),
298+
applicationActivities: nil
299+
)
300+
self.present(activityViewController, animated: true, completion: nil)
301+
}
302+
}
303+
272304
func branchShareLinkWillShare(_ shareLink: BranchShareLink) {
273305

274306
// Link properties, such as alias or channel can be overridden here based on the users'

0 commit comments

Comments
 (0)