Since the completionHandler
on UIActivityViewController
was deprecated in iOS 8, is there any way to determine which share extension/activity was used by the user?
You just need to use the new handler UIActivityViewControllerCompletionWithItemsHandler
:
typedef void (^UIActivityViewControllerCompletionWithItemsHandler)(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError);
Call it like this:
[yourActivityVC setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError){
}];
Additionally, if you're wondering about knowing what item was selected, you just need to ensure your activity items conform to the UIActivityItemSource
protocol;
UIActivityItemSource Protocol Documentation
setCompletionWithItemsHandler is iOS8 only. If you need to support iOS6-7 then:
[yourActivityVC setCompletionHandler:^(NSString *activityType, BOOL completed){
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With