PhoneCallOriginManager.SetCallOrigin(Guid, PhoneCallOrigin) Method

Definition

Sets the call origin when a phone call comes in.

public:
 static void SetCallOrigin(Platform::Guid requestId, PhoneCallOrigin ^ callOrigin);
 static void SetCallOrigin(winrt::guid const& requestId, PhoneCallOrigin const& callOrigin);
/// [Windows.Foundation.Metadata.Deprecated("PhoneCallOriginManager is deprecated and might not work for all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 458752, "Windows.ApplicationModel.Calls.CallsPhoneContract")]
 static void SetCallOrigin(winrt::guid const& requestId, PhoneCallOrigin const& callOrigin);
public static void SetCallOrigin(Guid requestId, PhoneCallOrigin callOrigin);
[Windows.Foundation.Metadata.Deprecated("PhoneCallOriginManager is deprecated and might not work for all platforms. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 458752, "Windows.ApplicationModel.Calls.CallsPhoneContract")]
public static void SetCallOrigin(Guid requestId, PhoneCallOrigin callOrigin);
function setCallOrigin(requestId, callOrigin)
Public Shared Sub SetCallOrigin (requestId As Guid, callOrigin As PhoneCallOrigin)

Parameters

requestId
Guid

Platform::Guid

winrt::guid

The unique identifier for this phone call. This is retrieved from the targetId of the PhoneCallOriginDataRequestTriggerDetails

callOrigin
PhoneCallOrigin

The call information for the incoming call.

Attributes

Windows requirements

App capabilities
phoneCallHistory phoneCallHistorySystem

Remarks

Before attempting to call this method, make sure of the following.

  • You declare the PhoneCall capability in your app manifest file as follows: <uap:Capability Name="phoneCall" />
  • Your application has a background task that binds the PhoneCallOriginDataRequestTriggerDetails trigger.
  • Your application can make phone calls (under Settings -> Privacy -> Phone calls).

If any of these are not true, SetCallOrigin will return an access denied error.

This method should be invoked in the background when the application is triggered by the PhoneCallOriginDataRequestTriggerDetails.

The following example shows how to set the location of the origin in response to a trigger.

public sealed class CallOriginLookupBackgroundTask : IBackgroundTask
{
    public async void Run(IBackgroundTaskInstance taskInstance)
    {

        PhoneCallOriginDataRequestTriggerDetails callDetails =
               (PhoneCallOriginDataRequestTriggerDetails)taskInstance.TriggerDetails;

        var deferral = taskInstance.GetDeferral();
        //look up local data source for call's location and category
        PhoneCallOrigin data = LocalLookupForCallerData(callDetails.PhoneNumber);
        //set phone call origin
        PhoneCallOriginManager.SetCallOrigin(callDetails.targetId, data);

        deferral.Complete();
    }
}

Applies to