这是可以实现的。正如您所说,您必须为您的应用程序创建自定义 URL 方案(如果有人不知道怎么做,这里是教程)。
现在您必须添加kABPersonSocialProfileProperty
到您的联系人(现有的或新的)。
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, nil);
ABRecordRef contact = ABPersonCreate();
/* implement standard contact info */
/* the social part below */
ABMultiValueRef social = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
ABMultiValueAddValueAndLabel(social, (__bridge CFTypeRef)([NSDictionary dictionaryWithObjectsAndKeys:
@"your app service name ", kABPersonSocialProfileServiceKey, //will be visible in contact
@"contact firstname / lastname / identifier", kABPersonSocialProfileUsernameKey, //will be visible in contact
@"your app custom url scheme", kABPersonSocialProfileURLKey, //url which will be open onclick event
nil]), (__bridge CFStringRef)@"your app special identifier", NULL); //to know to which app this social belongs to. I believe it is for search purposes
ABRecordSetValue(contact, kABPersonSocialProfileProperty, social, NULL);
CFRelease(social);
/* save contact */
为了完整起见,这里是教程,它深入解释了如何创建联系人并将其添加到地址簿。
希望它会帮助某人。