user3236289
user3236289

Reputation:

This item cannot be shared. Please select different item WhatsApp Share Extension Failure IOS

I want to share contact by using whatsapp from my app. I create vcf file and sent it UIActivityViewController. However whatsapp says ; This item cannot be shared. Please select different item

I used code is that:

- (NSString *)vCardRepresentation:(NSString*)message

{

NSArray *arr=[message componentsSeparatedByString:@","];

NSString *fname,*image,*phone,*Email;
fname=[arr objectAtIndex:0];
phone=[arr objectAtIndex:1];
Email=[arr objectAtIndex:2];
image=[arr objectAtIndex:3];

NSMutableArray *mutableArray = [[NSMutableArray alloc] init];


[mutableArray addObject:@"BEGIN:VCARD"];
[mutableArray addObject:@"VERSION:3.0"];

[mutableArray addObject:[NSString stringWithFormat:@"N:;Alper KOC;;;"]];
[mutableArray addObject:[NSString stringWithFormat:@"FN:Alper KOC"]];
[mutableArray addObject:[NSString stringWithFormat:@"TEL;type=CELL;type=VOICE;waid=905416050594:+90 541 605 0594"]];


[mutableArray addObject:@"END:VCARD"];

NSString *string = [mutableArray componentsJoinedByString:@"\n"];



return string;

}

 NSString * strVCard = [self vCardRepresentation:message.message];
        NSError * err;
        [strVCard writeToFile:[NSString stringWithFormat:@"%@/%@",documentsDirectory,@"data.vcf"] atomically:YES encoding:NSUTF8StringEncoding error:&err];

        [items addObject:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@",documentsDirectory,@"data.vcf"]]];


 self.activityViewController = [[customactivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
[self presentViewController:self.activityViewController animated:YES completion:nil];

Upvotes: 0

Views: 507

Answers (1)

BHAVIK
BHAVIK

Reputation: 899

Please Use CNContactVCardSerialization For VCARD Generating.

Upvotes: 0

Related Questions