0
我想通過使用WhatsApp從我的應用程序共享聯繫人。 我創建vcf文件並將其發送給UIActivityViewController。然而,Whatsapp說:此項目不能共享。請選擇不同的項目此項目不能共享。請選擇不同的項目WhatsApp共享擴展失敗IOS
我使用的代碼是:
- (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];