Nis*_*ant 7 iphone objective-c ios contacts-framework
要求:我将一些联系人与图片一起保存到用户的iPhone中(尺寸与设备相同).我希望每当联系人呼叫该设备时,此图片都会显示在FULLSCREEN上.
注意示例: 当呼叫者被识别为垃圾邮件时,Truecaller iOS应用程序显示为红色图像
代码:这是我用来保存联系人数据的代码.我在用Contacts.framework
CNMutableContact *newContact = [CNMutableContact new];
newContact.imageData = UIImagePNGRepresentation([UIImage imageNamed:@"blue_bg.png"]);
newContact.contactType = CNContactTypePerson;
newContact.givenName = user.firstName;
newContact.middleName = user.middleName;
newContact.familyName = user.lastName;
NSArray *numbers = [[NSArray alloc] initWithArray:@[[CNLabeledValue labeledValueWithLabel:@"Main" value:[CNPhoneNumber phoneNumberWithStringValue:user.mobileNumber.stringValue]]]];
newContact.phoneNumbers = numbers;
CNContactStore *store = [CNContactStore new];
CNSaveRequest *saveReq = [CNSaveRequest new];
[saveReq addContact:newContact toContainerWithIdentifier:nil];
NSError *error = nil;
[store executeSaveRequest:saveReq error:&error];
if (error) {
NSLog(@"Contact Save ERROR: %@", error.localizedDescription);
}
Run Code Online (Sandbox Code Playgroud)
当前场景:我在iOS中获取此图像,Contacts App
但当用户在iPhone上调用时,它不会显示.Truecaller是如何做到的?我在这里错过了什么?
归档时间: |
|
查看次数: |
1178 次 |
最近记录: |