UIActivityViewController Share text in whats app a

2020-04-08 12:00发布

问题:

In my application I used UIActivityViewController to share text in Whatsapp, Facebook and Twitter etc.

I am working in iOS 9 and Xcode Version 7.2. When I click on Whatsapp icon and click on particular contact person for share then pop up the following alert view:

When I click on OK, I get the following warning in debug pane:

plugin net.whatsapp.WhatsApp.ShareExtension invalidated

and i also set LSApplicationQueriesSchemes to whatsapp in .plist file but it didn't work.

I want to share text in all sharing option without any customized control.

Thanks in advance.

回答1:

I had that problem.. It is caused most probably by using NSString instead of NSURL, here is a working code:

-(void) share {
NSString* shareText = @"Sharing an eddress with you";
NSURL *website = [NSURL URLWithString:@"http://eddress.co/EDDRSS"];
NSArray *shareArray = @[shareText, website];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:shareArray applicationActivities:nil];

[activityVC setValue:@"Someone shared an eddress with you" forKey:@"subject"];

NSArray *excludeActivities = @[UIActivityTypeAirDrop,
                               UIActivityTypePrint,
                               UIActivityTypeAssignToContact,
                               UIActivityTypeSaveToCameraRoll,
                               UIActivityTypeAddToReadingList,
                               UIActivityTypePostToFlickr,
                               UIActivityTypePostToVimeo];

activityVC.excludedActivityTypes = excludeActivities;

[self.navigationController presentViewController:activityVC animated:YES completion:nil];
}