Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine which share extension was used

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?

like image 743
edc1591 Avatar asked Sep 23 '14 15:09

edc1591


2 Answers

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

like image 120
Tommy Devoy Avatar answered Sep 24 '22 20:09

Tommy Devoy


setCompletionWithItemsHandler is iOS8 only. If you need to support iOS6-7 then:

[yourActivityVC setCompletionHandler:^(NSString *activityType, BOOL completed){

}];
like image 40
Oren Avatar answered Sep 23 '22 20:09

Oren