I am trying to use the UIActivityViewControllerCompletionHandler
, but i dont quite get how..
I want to detect when the user finishes or dismisses this
With iOS 8 completionHandler
is deprecated, so you will want to provide alternative completionWithItemsHandler
. It also allows to handle if extension modified data you set (say Photo extension). See Documentation
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[text, URL, image] applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeAirDrop, UIActivityTypeAddToReadingList];
// check if new API supported
if ([activityViewController respondsToSelector:@selector(completionWithItemsHandler)]) {
activityViewController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
// When completed flag is YES, user performed specific activity
};
} else {
activityViewController.completionHandler = ^(NSString *activityType, BOOL completed) {
// When completed flag is YES, user performed specific activity
};
}