将图像保存为联系人图片,并在来电时显示

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是如何做到的?我在这里错过了什么?

小智 -1

如果该图像显示在“通讯录”应用程序中,那么当您接到该人的电话时,它应该会显示。