@@ -206,6 +206,17 @@ - (IBAction)simulateContentAccessButtonTouchUpInsideButtonTouchUpInside:(id)send
206206 [self showAlert: @" Content Access Registered" withDescription: @" " ];
207207}
208208
209+ - (NSDateFormatter *) dateFormatter {
210+ if (_dateFormatter) return _dateFormatter;
211+
212+ _dateFormatter = [[NSDateFormatter alloc ] init ];
213+ _dateFormatter.locale = [NSLocale localeWithLocaleIdentifier: @" en_US_POSIX" ];
214+ _dateFormatter.dateFormat = @" yyyy-MM-dd'T'HH:mm:ssX" ;
215+ _dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT: 0 ];
216+ return _dateFormatter;
217+ }
218+
219+ #pragma mark - Share a Branch Link
209220
210221- (IBAction )oldShareLinkButtonTouchUpInside : (id )sender {
211222 // This method uses the old way of sharing Branch links.
@@ -216,23 +227,17 @@ - (IBAction)oldShareLinkButtonTouchUpInside:(id)sender {
216227 [linkProperties addControlParam: @" $desktop_url" withValue: desktop_url];
217228 [linkProperties addControlParam: @" $ios_url" withValue: ios_url];
218229
219- [self .branchUniversalObject showShareSheetWithLinkProperties: linkProperties andShareText: shareText fromViewController: self .parentViewController completion: ^(NSString *activityType, BOOL completed) {
220- if (completed) {
221- NSLog (@" %@ " , [NSString stringWithFormat: @" Branch TestBed: Completed sharing to %@ " , activityType]);
222- } else {
223- NSLog (@" %@ " , [NSString stringWithFormat: @" Branch TestBed: Sharing failed" ]);
230+ [self .branchUniversalObject showShareSheetWithLinkProperties: linkProperties
231+ andShareText: shareText
232+ fromViewController: self .parentViewController
233+ completion: ^(NSString *activityType, BOOL completed) {
234+ if (completed) {
235+ NSLog (@" Branch TestBed: Completed sharing to %@ " , activityType);
236+ } else {
237+ NSLog (@" Branch TestBed: Sharing failed" );
238+ }
224239 }
225- }];
226- }
227-
228- - (NSDateFormatter *) dateFormatter {
229- if (_dateFormatter) return _dateFormatter;
230-
231- _dateFormatter = [[NSDateFormatter alloc ] init ];
232- _dateFormatter.locale = [NSLocale localeWithLocaleIdentifier: @" en_US_POSIX" ];
233- _dateFormatter.dateFormat = @" yyyy-MM-dd'T'HH:mm:ssX" ;
234- _dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT: 0 ];
235- return _dateFormatter;
240+ ];
236241}
237242
238243- (IBAction )shareLinkButtonTouchUpInside : (id )sender {
@@ -258,8 +263,38 @@ - (IBAction)shareLinkButtonTouchUpInside:(id)sender {
258263 [shareLink presentActivityViewControllerFromViewController: self anchor: nil ];
259264}
260265
266+ - (IBAction )shareLinkAsActivityItem : (id )sender {
267+ // Share as an activity item.
268+
269+ BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc ] init ];
270+ linkProperties.feature = feature;
271+ linkProperties.campaign = @" sharing campaign" ;
272+ [linkProperties addControlParam: @" $desktop_url" withValue: desktop_url];
273+ [linkProperties addControlParam: @" $ios_url" withValue: ios_url];
274+
275+ BranchShareLink *shareLink =
276+ [[BranchShareLink alloc ]
277+ initWithUniversalObject: self .branchUniversalObject
278+ linkProperties: linkProperties];
279+
280+ shareLink.title = @" Share your test link!" ;
281+ shareLink.delegate = self;
282+ shareLink.shareText = [NSString stringWithFormat:
283+ @" Shared from Branch's Branch-TestBed at %@ ." ,
284+ [self .dateFormatter stringFromDate: [NSDate date ]]];
285+
286+ UIActivityViewController *activityController =
287+ [[UIActivityViewController alloc ]
288+ initWithActivityItems: shareLink.activityItems
289+ applicationActivities: nil ];
290+
291+ if (activityController) {
292+ [self presentViewController: activityController animated: YES completion: nil ];
293+ }
294+ }
295+
261296- (void ) branchShareLinkWillShare : (BranchShareLink*)shareLink {
262- // This example shows changing the share text.
297+ // This delegate example shows changing the share text.
263298 //
264299 // Link properties, such as alias or channel can be overridden here based on the users'
265300 // choice stored in shareSheet.activityType.
@@ -283,6 +318,8 @@ - (void) branchShareLink:(BranchShareLink*)shareLink
283318 }
284319}
285320
321+ #pragma mark - Commerce Events
322+
286323- (IBAction ) sendCommerceEvent : (id )sender {
287324 BNCProduct *product = [BNCProduct new ];
288325 product.price = [NSDecimalNumber decimalNumberWithString: @" 1000.99" ];
0 commit comments