Reputation:
Is it possible to use different activity items for each activity activities in a UIActivityViewController
? For example, I have the following code:
NSArray *objectsToShare = @[schemeURL, wordedString];
controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
// Exclude all activities except AirDrop.
NSArray *excludedActivities = @[UIActivityTypePostToTwitter,
UIActivityTypePostToWeibo,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludedActivities;
[self presentViewController:controller animated:YES completion:nil];
I want to set the data to send to Facebook to the wordedString
property and set the data to send via AirDrop to the property schemeURL
. Is this possible? Thanks in advance.
Upvotes: 2
Views: 2984
Reputation: 1204
You can subclass UIActivityItemProvider and following method can be used to check activity type.. try it out
//- Returns the data object to be acted upon. (required)
- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType
{
if ([activityType isEqualToString:UIActivityTypePostToFacebook]) {
NSString *theText = @"Some text for Facebook";
return theText;
}
if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {
NSString *theText = @"Some text for Twitter";
return theText;
}
if ([activityType isEqualToString:UIActivityTypePostToWeibo]) {
NSString *theText = @"Some text for Weibo";
return theText;
}
if ([activityType isEqualToString:UIActivityTypeMail]) {
NSString *theText = _someText;
return theText;
}
if ([activityType isEqualToString:kYourCustomMailType]) {
NSString *theText = @"Some text for your Custom Type";
return theText;
}
return @"Some default text";
}
Upvotes: 2