标签: abperson

ABAddressBook - 如何查找是否从iPhone的地址簿中修改或删除了特定联系人?

我正在开发一个聊天应用程序.我需要保存联系人.所以我在我的核心数据实体中保存ABAddressBook中的所有联系人.问题是如何知道联系人是否被修改或从iPhone的地址簿中删除?这样我将从我的核心数据实体修改或删除该联系人.

if ABRecordGetRecordID(person) can be used as unique key or not
Run Code Online (Sandbox Code Playgroud)

给定belew是在核心数据中添加联系人的代码.

ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, nil);
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople( addressBookRef );
CFIndex nPeople = ABAddressBookGetPersonCount( addressBookRef );

for ( int i = 0; i < nPeople; i++ )
{
    ABRecordRef person = CFArrayGetValueAtIndex( allPeople, i );
 } 

 NSString* firstName = (__bridge_transfer NSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty);


    if ([firstName hasPrefix:@"Protected by True"])
    {
        continue;
    }
    else if([firstName hasPrefix:@"Identified As Spam"])
    {
        continue;
    }


    NSString* lastName  = (__bridge_transfer NSString*)ABRecordCopyValue(person,kABPersonLastNameProperty);

    NSString *userEmail = …
Run Code Online (Sandbox Code Playgroud)

iphone contacts abaddressbook abrecord abperson

7
推荐指数
1
解决办法
387
查看次数

在iOS9 CloudKit/ABPerson中查找用户名或名/姓(ABAddressBook)

iOS9不推荐使用CloudKitABPerson的用户信息功能.

例如,在CKDiscoveredUserInfo的属性中

firstName"在iOS 9.0中已弃用

lastName"在iOS 9.0中已弃用

我想要以前在iOS8 CloudKit中提供的姓氏和名字.

如何在iOS9 CloudKit,ABPerson或其他东西中检索类似的信息?

缺乏恩典方法就是这个

[[UIDevice currentDevice] name]; 

 NSArray *nameArray = [[NSHost currentHost] names];
 NSString *user = [nameArray objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)

两者都打印出例如John'iPhone.

abaddressbook abperson cloudkit ios9

7
推荐指数
1
解决办法
2672
查看次数

iOS:无法获取用户的电子邮件地址

我想获取用户邮件地址,如此主题所示:在Cocoa中获取用户的默认电子邮件地址

但当我尝试时:

NSString *theEmailAddressWeWantToObtain = @"";
ABPerson *aPerson = [[ABAddressBook sharedAddressBook] me];
ABMultiValue *emails = [aPerson valueForProperty:kABEmailProperty];
if([emails count] > 0)
        theEmailAddressWeWantToObtain = [emails valueAtIndex:0];
Run Code Online (Sandbox Code Playgroud)

我有这些错误:

  • 使用未声明的标识符'aPerson'
  • 使用未声明的标识符'ABAddressBook'
  • 未知类型'ABMultiValue'

我已经链接了AddressBook和AddressBookUI,并导入了AddressBook/AddressBook.h

怎么了 ?

email addressbook ios abperson

6
推荐指数
1
解决办法
4709
查看次数

如何阅读电话簿号码标签?

我知道如何从中获取电话号码ABRecordRef,但我现在想要的是获取号码的类型,即其标签为字符串:

const CFStringRef kABPersonPhoneIPhoneLabel;
const CFStringRef kABPersonPhoneMainLabel;
const CFStringRef kABPersonPhoneHomeFAXLabel;
const CFStringRef kABPersonPhoneWorkFAXLabel;
const CFStringRef kABPersonPhonePagerLabel;
Run Code Online (Sandbox Code Playgroud)

以下是我获取数字的方法:

//get all phone numbers                   
NSArray *phoneNumbersArray = (NSArray*)ABMultiValueCopyArrayOfAllValues(phoneNumberProperty);
NSInteger numbersCounter = 0;
for(numbersCounter = 0; numbersCounter < [phoneNumbersArray count]; numbersCounter++)
{
     NSString currentPhoneNumber = [phoneNumbersArray objectAtIndex:indexPhoneNumber];

      // here i would like to read the type of phone number 
      // NSLog(@"NumberType:%@",numberType);                    
 }
Run Code Online (Sandbox Code Playgroud)

我尝试了各种各样的东西,我已经阅读了ABPerson参考资料,我不知道如何获得电话号码类型?

abaddressbook ios abperson

4
推荐指数
1
解决办法
3656
查看次数