I have the text in activity Items but now it share on WhatsApp or Facebook, this method share for each app the same text. is it possible to share different text for each app ?
- (void)share {
NSString *text = @"share test";
NSArray * activityItems = @[[NSString stringWithFormat:@"%@", text], [NSURL URLWithString:@"http://www.test.co"]];
NSArray * applicationActivities = nil;
NSArray * excludeActivities = @[UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeMessage];
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityController.excludedActivityTypes = excludeActivities;
[self presentViewController:activityController animated:YES completion:nil];
[activityController setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
NSLog(@"The setCompletionWithItemsHandler completed = %i", completed);
if (completed) {
NSLog(@"The selected activity was %@", activityType);
if ( [activityType isEqualToString:UIActivityTypeMail]) {
NSLog(@"Mail sended");
} else if ( [activityType isEqualToString:UIActivityTypePostToTwitter]) {
NSLog(@"Post on twitter, ok!");
} else if ( [activityType isEqualToString:UIActivityTypePostToFacebook]) {
NSLog(@"Post on facebook, ok!");
} else if ( [activityType isEqualToString:UIActivityTypeMessage]) {
NSLog(@"SMS sended!");
}
}
}];
}
Short answer: No.
But you can use the open App with URL method and pass an parameter to that App. When using that method you have to use a custom UI and can not use the UIActivityViewController. (As far as i know)
So, it is possible, if you want to have multiple buttons like: "Share with WhatsApp" "Share with Facebook" etc.