Share via


Remove a Contact from the Contact List

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

To remove a contact from a contact list, a Unified Communications Client API application publishes an already published contact category instance, with the PublicationOperation property setting to UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_REMOVE. Previously published contacts are provisioned on a client with a self-subscription to the contacts category. Each category instance received in the contacts context can be removed using the functionality illustrated by the following example.

The programming pattern involves the following steps:

  1. Using the contact object passed as an IUccCategoryInstance, create a publishable category instance from the passed contact object.
  2. Set the PublicationOperation property value to UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_REMOVE.
  3. Publish the newly configured contacts category instance.

The following C# code snippet publishes a request to remove a contact from a user's published contact list.

partial class ContactManager
{
    /// <summary>
    /// Removes a contact from the contact list by republishing it 
    /// while setting the PublicationOperation to 
    /// UCC_PUBLICATION_OPERATION_TYPE.UCCPOT.REMOVE
    /// </summary>
    /// <param name="cat">a contact category instance to be removed</param>
    public void removeContact(IUccCategoryInstance contact)
    { 
        try
        {
            IUccCategoryInstance cat = contact.CreatePublishableCategoryInstance();
            cat.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_REMOVE;
            
            IUccPublication pub = publicationManager.CreatePublication();
            UCC_Advise<_IUccPublicationEvent>(pub, this);
            pub.AddPublishableCategoryInstance(cat);
            pub.Publish(null);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}

See Also

Concepts

Create Contact List Subscription
Add a Contact to the Contact List
Remove a Contact from the Contact List
Granting Permissions to View Published Presence States
Presence Availability State
Sample Contact Presence Handling Class
Category and Category Instances
Publication and Subscription Objects