8

Requirement: I am saving some contacts into the user's iPhone along with a picture (dimensions same as the device). I want this picture to be displayed ON FULLSCREEN whenever the contact calls on that device.

Noticed Example: Truecaller iOS app shows as Red image when the caller is Identified as Spam

Code: This is code I have used to save the contacts data. I am using 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);
}

Current Scenario: I am getting this image in the iOS Contacts App but its not displayed when that user calls on the iPhone. How does Truecaller do it? What am I missing here?

Nishant
  • 12,529
  • 9
  • 59
  • 94
  • One of my app i did the same in swift : let contact = CNMutableContact() let image:UIImage = UIImage(imageLiteral: "cat.png") if let imageData:NSData = UIImagePNGRepresentation(image) { contact.imageData = imageData // The profile picture as a NSData object } – SaRaVaNaN DM Jul 14 '16 at 06:46
  • @SaRaVaNaNDM: I have done the same thing in ObjC. Were you getting the desired result (full screen caller image)? – Nishant Jul 14 '16 at 06:49
  • Yep i'm getting. I guess its iOS issue, sometimes it won't show the image. – SaRaVaNaN DM Jul 14 '16 at 08:14

1 Answers1

0

If the image shows up in the Contacts App it should show up when you're getting called by that person.

  • It should be happening but it isn't. Only the contact name initials are showing when incoming call. Not sure where I'm going wrong with this simple thing. Do you have some code that is working? – Nishant Jul 13 '16 at 18:35
  • From another website: "It depends from where you selected the picture: only pictures selected from the Camera Roll will be displayed fullscreen." so you probably need to change something in your code to make it work then. – Matthijs Otterloo Jul 13 '16 at 18:39
  • I've read about this before, Will try to workaround this. But then how does Truecaller app do it? – Nishant Jul 13 '16 at 18:43
  • I don't know if it's possible, but it might be they just save that image to your camera roll, set a contact image to the latest image in the camera roll, and then remove the image from the camera roll. (I don't know if this works and if it's possible) but this might be the solution they use. – Matthijs Otterloo Jul 14 '16 at 06:58
  • I dont think this is the case with Truecaller because it never asks for CameraRoll/Photos access permission. – Nishant Jul 14 '16 at 07:00