@@ -120,18 +120,28 @@ - (UIActivityItemProvider *)getBranchActivityItemWithLinkProperties:(BranchLinkP
120120 alias: linkProperties.alias];
121121}
122122
123- - (void )showShareSheetWithShareText : (NSString *)shareText andCallback : (callback) callback {
124- [self showShareSheetWithLinkProperties: nil andShareText: shareText fromViewController: nil andCallback: callback ];
123+ - (void )showShareSheetWithShareText : (NSString *)shareText completion : (shareCompletion) completion {
124+ [self showShareSheetWithLinkProperties: nil andShareText: shareText fromViewController: nil completion: completion ];
125125}
126126
127- - (void )showShareSheetWithLinkProperties : (BranchLinkProperties *)linkProperties andShareText : (NSString *)shareText fromViewController : (UIViewController *)viewController andCallback : (callback) callback {
127+ - (void )showShareSheetWithLinkProperties : (BranchLinkProperties *)linkProperties andShareText : (NSString *)shareText fromViewController : (UIViewController *)viewController completion : (shareCompletion) completion {
128128 UIActivityItemProvider *itemProvider = [self getBranchActivityItemWithLinkProperties: linkProperties];
129129 NSMutableArray *items = [NSMutableArray arrayWithObject: itemProvider];
130130 if (shareText) {
131131 [items addObject: shareText];
132132 }
133133 UIActivityViewController *shareViewController = [[UIActivityViewController alloc ] initWithActivityItems: items applicationActivities: nil ];
134134
135+ if ([shareViewController respondsToSelector: @selector (completionWithItemsHandler )]) {
136+ shareViewController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
137+ if (completion) {
138+ completion (activityType, completed);
139+ }
140+ };
141+ } else {
142+ shareViewController.completionHandler = completion;
143+ }
144+
135145 UIViewController *presentingViewController;
136146 if (viewController && [viewController respondsToSelector: @selector (presentViewController:animated:completion: )]) {
137147 presentingViewController = viewController;
@@ -154,13 +164,26 @@ - (void)showShareSheetWithLinkProperties:(BranchLinkProperties *)linkProperties
154164 if ([presentingViewController respondsToSelector: @selector (popoverPresentationController )]) {
155165 shareViewController.popoverPresentationController .sourceView = presentingViewController.view ;
156166 }
157- [presentingViewController presentViewController: shareViewController animated: YES completion: callback ];
167+ [presentingViewController presentViewController: shareViewController animated: YES completion: nil ];
158168 }
159169 else {
160170 NSLog (@" [Branch warning, fatal] No view controller is present to show the share sheet. Aborting." );
161171 }
162172}
163173
174+
175+ - (void )showShareSheetWithShareText : (NSString *)shareText andCallback : (callback)callback {
176+ [self showShareSheetWithLinkProperties: nil andShareText: shareText fromViewController: nil andCallback: callback];
177+ }
178+
179+ - (void )showShareSheetWithLinkProperties : (BranchLinkProperties *)linkProperties andShareText : (NSString *)shareText fromViewController : (UIViewController *)viewController andCallback : (callback)callback {
180+ [self showShareSheetWithLinkProperties: linkProperties andShareText: shareText fromViewController: viewController completion: ^(NSString *activityType, BOOL completed) {
181+ if (callback) {
182+ callback ();
183+ }
184+ }];
185+ }
186+
164187- (void )listOnSpotlight {
165188 [self listOnSpotlightWithCallback: nil ];
166189}
0 commit comments