2828
2929@interface TBBranchViewController () <UITableViewDelegate, UITableViewDataSource>
3030@property (nonatomic , strong ) TBTableData *tableData;
31- @property (nonatomic , strong ) BranchUniversalObject *branchUniversalObject;
31+ @property (nonatomic , strong ) BranchUniversalObject *universalObject;
32+ @property (nonatomic , strong ) BranchLinkProperties *linkProperties;
3233@property (nonatomic , weak ) IBOutlet UITableView *tableView;
3334@property (nonatomic , strong ) IBOutlet UINavigationItem *navigationItem;
3435@end
@@ -58,6 +59,11 @@ - (void)initializeTableData {
5859 section (@" Events" );
5960 row (@" Send Commerce Event" , sendCommerceEvent:);
6061
62+ section (@" Sharing" );
63+ row (@" ShareLink from table row" , sharelinkTableRow:);
64+ row (@" ShareLink no anchor" , sharelinkTableRowNilAnchor:);
65+ row (@" BUO Share from table row" , buoShareTableRow:);
66+
6167 section (@" Miscellaneous" );
6268 row (@" Show Local IP Addess" , showLocalIPAddress:);
6369
@@ -69,16 +75,16 @@ - (void)viewDidLoad {
6975 [super viewDidLoad ];
7076 [self initializeTableData ];
7177
72- _branchUniversalObject =
78+ _universalObject =
7379 [[BranchUniversalObject alloc ] initWithCanonicalIdentifier: cononicalIdentifier];
74- _branchUniversalObject .canonicalUrl = canonicalUrl;
75- _branchUniversalObject .title = contentTitle;
76- _branchUniversalObject .contentDescription = contentDescription;
77- _branchUniversalObject .imageUrl = imageUrl;
78- _branchUniversalObject .price = 1000 ;
79- _branchUniversalObject .currency = @" $" ;
80- _branchUniversalObject .type = type;
81- [_branchUniversalObject
80+ _universalObject .canonicalUrl = canonicalUrl;
81+ _universalObject .title = contentTitle;
82+ _universalObject .contentDescription = contentDescription;
83+ _universalObject .imageUrl = imageUrl;
84+ _universalObject .price = 1000 ;
85+ _universalObject .currency = @" $" ;
86+ _universalObject .type = type;
87+ [_universalObject
8288 addMetadataKey: @" deeplink_text"
8389 value: [NSString stringWithFormat:
8490 @" This text was embedded as data in a Branch link with the following characteristics:\n\n "
@@ -101,6 +107,14 @@ - (void)viewDidLoad {
101107 r.size .height *= 1 .75f ;
102108 versionLabel.frame = r;
103109 self.tableView .tableHeaderView = versionLabel;
110+
111+ // Add a share button item:
112+ UIBarButtonItem *barButtonItem =
113+ [[UIBarButtonItem alloc ]
114+ initWithBarButtonSystemItem: UIBarButtonSystemItemAction
115+ target: self
116+ action: @selector (buoShareBarButton: )];
117+ self.navigationItem .rightBarButtonItem = barButtonItem;
104118}
105119
106120#pragma mark - Table View Delegate & Data Source
@@ -178,7 +192,7 @@ - (IBAction)createBranchLink:(TBTableRow*)sender {
178192 [linkProperties addControlParam: @" $desktop_url" withValue: desktop_url];
179193 [linkProperties addControlParam: @" $ios_url" withValue: ios_url];
180194
181- [self .branchUniversalObject
195+ [self .universalObject
182196 getShortUrlWithLinkProperties: linkProperties
183197 andCallback: ^(NSString *url, NSError *error) {
184198 sender.value = url;
@@ -286,4 +300,46 @@ - (IBAction)showLocalIPAddress:(id)sender {
286300 ];
287301}
288302
303+ #pragma mark - Sharing
304+
305+ - (IBAction ) sharelinkTableRow : (id )sender {
306+ NSIndexPath *indexPath = [self .tableData indexPathForRow: sender];
307+ UITableViewCell *cell = [self .tableView cellForRowAtIndexPath: indexPath];
308+ BranchShareLink *shareLink =
309+ [[BranchShareLink alloc ]
310+ initWithUniversalObject: self .universalObject
311+ linkProperties: self .linkProperties];
312+ [shareLink presentActivityViewControllerFromViewController: self anchor: cell];
313+ }
314+
315+ - (IBAction ) sharelinkTableRowNilAnchor : (id )sender {
316+ BranchShareLink *shareLink =
317+ [[BranchShareLink alloc ]
318+ initWithUniversalObject: self .universalObject
319+ linkProperties: self .linkProperties];
320+ [shareLink presentActivityViewControllerFromViewController: self anchor: nil ];
321+ }
322+
323+ - (IBAction ) buoShareTableRow : (id )sender {
324+ NSIndexPath *indexPath = [self .tableData indexPathForRow: sender];
325+ UITableViewCell *cell = [self .tableView cellForRowAtIndexPath: indexPath];
326+ [self .universalObject showShareSheetWithLinkProperties: self .linkProperties
327+ andShareText: @" Ha ha"
328+ fromViewController: self
329+ anchor: cell
330+ completionWithError: ^ (NSString * _Nullable activityType, BOOL completed, NSError * _Nullable activityError) {
331+ BNCLogDebug (@" Done." );
332+ }];
333+ }
334+
335+ - (IBAction ) buoShareBarButton : (id )sender {
336+ [self .universalObject showShareSheetWithLinkProperties: self .linkProperties
337+ andShareText: @" Ha ha"
338+ fromViewController: self
339+ anchor: sender
340+ completionWithError: ^ (NSString * _Nullable activityType, BOOL completed, NSError * _Nullable activityError) {
341+ BNCLogDebug (@" Done." );
342+ }];
343+ }
344+
289345@end
0 commit comments