我想通过使用我的应用中的whatsapp来分享联系方式。 我创建了vcf文件并将其发送给UIActivityViewController。 然而whatsapp说;此项目无法共享。请选择不同的项目
我使用的代码就是:- (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];
答案 0 :(得分:0)
请使用CNContactVCardSerialization进行VCARD生成。