5

Sharing .vcf to WhatsApp using UIActivityViewController fails by showing plugin net.whatsapp.WhatsApp.ShareExtension invalidated error

Sharing image or text is working using UIActivityViewController, But sharing .vcf is not working with whatsapp (working fine for mail/message/messenger etc).

NSData *pVcfData     = [CNContactVCardSerialization dataWithContacts:[NSArray arrayWithObject:pContact] error:&pError]; // creating contact data from CNContactVCardSerialization

NSURL *pFileURL      = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:pFileNameWithAllowedCharacters]]; //  wrote the data to file

NSError *pWriteError = nil;

if ([pVcfData writeToURL:pFileURL options:NSDataWritingAtomic error:&pWriteError])
{
   NSArray *pActivityItems  =  @[pFileURL]; //  passed the file URL as ActivityItem for UIActivityViewController

   UIActivityViewController *pActivityVC = [[UIActivityViewController alloc] initWithActivityItems:pActivityItems applicationActivities:nil];

   [pActivityVC setValue:pContactName forKey:@"subject"];

   [self presentViewController:pActivityVC animated:YES completion:nil];
}

Is there any other method to share contact to whatsapp other than .vcf. Please share any suggestion.

Annie Dev
  • 282
  • 1
  • 10

0 Answers0