addressbook

Can't Access Contacts Sources on Device in iOS 6

我的未来我决定 提交于 2019-12-03 10:39:23
This code worked OK on iOS 5.1 and also does work in the iPhone simulator with iOS 6. It fails silently on my iPhone 4 running iOS 6. The end result is that I cannot add a person to the Contacts app. Neither of the following code snippets work (log follows each): ABRecordRef defaultSource = ABAddressBookCopyDefaultSource(_addressBook); NSLog(@"2 - defaultSource = %@", defaultSource); AB: Could not compile statement for query (ABCCopyArrayOfAllInstancesOfClassInSourceMatchingProperties): SELECT ROWID, Name, ExternalIdentifier, Type, ConstraintsPath, ExternalModificationTag, ExternalSyncTag,

Adding vCard data directly to the system Address Book

北城余情 提交于 2019-12-03 07:34:44
问题 I am designing a QR code reader, and it needs to detect and import contact cards in vCard format (.vcf). is there a way to add the card data to the system Address Book directly, or do I need to parse the vCard myself and add each field individually? 回答1: If you're running on iOS 5 or later, this code should do the trick: #import <AddressBook/AddressBook.h> // This gets the vCard data from a file in the app bundle called vCard.vcf //NSURL *vCardURL = [[NSBundle bundleForClass:self.class]

How do I get the cropping frame of the address book image data?

老子叫甜甜 提交于 2019-12-03 06:39:21
The AddressBook framework provides ABPersonCopyImageData for getting the contact image for each address book entry. This is great for the image data, but the user also sizes and crops the image for framing purposes. When I get the image data, I get the full image, and not the cropped image. How do I get the frame the user used to crop the image (or in lieu of that, how do I get access to the cropped image/data)? Sceeter iOS 4.1 adds a new method: ABPersonCopyImageDataWithFormat in ABPerson . I'm using it like this: NSData *imageData = [(NSData *)ABPersonCopyImageDataWithFormat(recordRef,

Is there any way to get the “Me” card from iPhone Address Book API?

房东的猫 提交于 2019-12-03 04:55:28
So I'm stumped on this one. In Mac OS X there is an easy way to get the "Me" card (the owner of the Mac/account) from the built-in address book API. Has anyone found a way to find out which contact (if it exists) belongs to the owner of the iPhone? You could use the undocumented user default: [[NSUserDefaults standardUserDefaults] objectForKey:@"SBFormattedPhoneNumber"]; and then search the address book for the card with that phone number. Keep in mind that since the User Default is undocumented, Apple could change at any time and you may have trouble getting into the App Store. Another

How to select a contact with ABPeoplePickerNavigationController in Swift?

时光毁灭记忆、已成空白 提交于 2019-12-03 01:45:40
I have added the ABPeoplePickerNavigationController into my first view controller. I want that when I select a contact show the info to show in other view controller, but I'm trying use my code and this not show never when I click in a contact. This only open the contact into native app ABPeoplePickerNavigationController . var people = ABPeoplePickerNavigationController() var addressBook: ABAddressBookRef? func extractABAddressBookRef(abRef: Unmanaged<ABAddressBookRef>!) -> ABAddressBookRef? { if let ab = abRef { self.view.addSubview(people.view) return Unmanaged<NSObject>.fromOpaque(ab

Adding vCard data directly to the system Address Book

筅森魡賤 提交于 2019-12-02 21:04:50
I am designing a QR code reader, and it needs to detect and import contact cards in vCard format (.vcf). is there a way to add the card data to the system Address Book directly, or do I need to parse the vCard myself and add each field individually? Carter Allen If you're running on iOS 5 or later, this code should do the trick: #import <AddressBook/AddressBook.h> // This gets the vCard data from a file in the app bundle called vCard.vcf //NSURL *vCardURL = [[NSBundle bundleForClass:self.class] URLForResource:@"vCard" withExtension:@"vcf"]; //CFDataRef vCardData = (CFDataRef)[NSData

How to retrieve address book contacts with Swift?

一世执手 提交于 2019-12-02 20:53:00
I don't understand why my code doesn't compile with Swift. I am trying to convert this Objective-C code: CFErrorRef error = NULL; ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &error); if (addressBook != nil) { NSLog(@"Succesful."); NSArray *allContacts = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); } This is my current rendition in Swift: var error:CFErrorRef var addressBook = ABAddressBookCreateWithOptions(nil, nil); if (addressBook != nil) { println("Succesful."); var allContacts:CFArrayRef = ABAddressBookCopyArrayOfAllPeople(addressBook

How to search the iphone address book for a specific phone number?

孤街浪徒 提交于 2019-12-02 19:36:52
I am developing an app that connects to another iphone using bonjour. One of its features is when I connect to the other device it will automatically check if I have the other persons phone number. So my problem is how do I check my address book for the phone number provided by the other device? Here's an example extracted from one of my address book methods. I wasn't searching by phone number but this gives you an idea have how to move forward with what you need: - (void) scanAddressBookSample { NSUInteger i; NSUInteger k; ABAddressBookRef addressBook = ABAddressBookCreate(); NSArray *people

How to specify a group when displaying an ABPeoplePickerNavigationController

半世苍凉 提交于 2019-12-02 08:26:45
问题 How do you specify a group when initially displaying an ABPeoplePickerNavigationController (so it doesn't automatically display "All Contacts")? 回答1: Yeah, I do. I had to make it work. Set your class as the delegate of the people picker (pp.delegate = self;) Then implement: - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if([navigationController.viewControllers count] > 1) {

Is it possible to retrieve the create time of the iPhone contacts record?

天涯浪子 提交于 2019-12-02 06:48:46
问题 I want to ask a question about iPhone. Is it possible to retrieve the creation time from the iPhone contacts of each record? Thank you. 回答1: Yes. You want the kABPersonCreationDateProperty . See the reference. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeStyle:NSDateFormatterMediumStyle]; [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; ABAddressBookRef addressBook = ABAddressBookCreate(); NSArray* allPeople = (NSArray*)