There is a way, but it includes a private API .
Sometimes Apple makes exceptions, especially if you are fixing a bug.
Let's dive into the details ...
UIActivityViewController has a private method called _availableActivitiesForItems: which returns an array of UISocialActivity objects.
UISocialActivity has an interesting property called "activityType" that returns the type of action in the domain format.
After some tests, I managed to discover the types of actions "Reminder and notes":
- com.apple.reminders.RemindersEditorExtension
- com.apple.mobilenotes.SharingExtension
Unfortunately , passing these two types to ".excludedActivityTypes" does not matter.
"_availableActivitiesForItems:" to the rescue!
OLD WAY :
Update : I found a better way to do this.
The first solution I posted does not work in some cases, so it should not be considered stable.
Title:
Implementation:
@implementation ActivityViewController - (id)_availableActivitiesForItems:(id)arg1 { id activities = [super _availableActivitiesForItems:arg1]; NSMutableArray *filteredActivities = [NSMutableArray array]; [activities enumerateObjectsUsingBlock:^(UISocialActivity* _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if (![[obj activityType] isEqualToString:@"com.apple.reminders.RemindersEditorExtension"] && ![[obj activityType] isEqualToString:@"com.apple.mobilenotes.SharingExtension"]) { [filteredActivities addObject:obj]; } }]; return [NSArray arrayWithArray:filteredActivities]; } @end
NEW WAY :
Title:
@interface UIActivityViewController (Private) - (BOOL)_shouldExcludeActivityType:(UIActivity*)activity; @end @interface ActivityViewController : UIActivityViewController @end
Implementation:
@implementation ActivityViewController - (BOOL)_shouldExcludeActivityType:(UIActivity *)activity { if ([[activity activityType] isEqualToString:@"com.apple.reminders.RemindersEditorExtension"] || [[activity activityType] isEqualToString:@"com.apple.mobilenotes.SharingExtension"]) { return YES; } return [super _shouldExcludeActivityType:activity]; }
@end
" Illegal ", but it works.
It would be great to know if it really passes the Apple test.
Matteo Pacini Oct 22 '15 at 17:05 2015-10-22 17:05
source share