How to set contact picture?

I am using ngCordova-Contact plugin, which works fine. But I cant find any solution to set a picture for an contact? My source is an base64 encoded picture - extracted from an existing contact.

If someone knows any examples or documentation regarding this topic…

This post might help you, tell me if this is what you want

Thanks for your answer, displaying the Picture is no problem - i want to set the Contact photo in Contacts on the Device.

Oh, do you mean modify the contact picture ?
Have you looked into GitHub - apache/cordova-plugin-contacts: Apache Cordova Plugin contacts ?

Sure, the process to create a contact is clear and works like a charm. But how to upload and set the contact picture?

The object has a property “url” but how to set a new picture for a contact. I would think it must be something like:

  1. Upload picture to device
  2. Find out “content://” url on device ?

I have searched for hours but no example or documentation found (;

I’ve never worked with contacts, but if you used this to create a contact (see below), can’t you just do contact.photos[0] = yourBase64Image; ?
Sorry not to be able to help more

function onSuccess(contact) {
   alert("Save Success");
};

function onError(contactError) {
  alert("Error = " + contactError.code);
};

 // create a new contact object
var contact = navigator.contacts.create();
contact.displayName = "Plumber";
contact.nickname = "Plumber";            // specify both to support all devices

// populate some fields
var name = new ContactName();
name.givenName = "Jane";
name.familyName = "Doe";
contact.name = name;

// save to device
contact.save(onSuccess,onError);

Thanks for your help, but not working (-: I hope someone else has an idea about this topic.

Ok… seems to be an bug in Cordova Contacts Plugin. Regarding some documentation you can pass a base64 string like this:

theContact.photos[0] = new ContactField('base64', base64, true)

But the function in contacts plugin, to resolve this does not support this format. Now i have modified the Java Class to handle base64 … works…

Thanks for the update with your solution, good luck for the rest !