PhoneCallOriginManager.SetCallOrigin(Guid, PhoneCallOrigin) 方法

定义

设置电话呼叫传入时的呼叫源。

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)

参数

requestId
Guid

Platform::Guid

winrt::guid

此电话呼叫的唯一标识符。 这是从 PhoneCallOriginDataRequestTriggerDetailstargetId 检索的

callOrigin
PhoneCallOrigin

传入呼叫的呼叫信息。

属性

Windows 要求

应用功能
phoneCallHistory phoneCallHistorySystem

注解

在尝试调用此方法之前,请确保满足以下条件。

  • 在应用清单文件中声明 PhoneCall 功能,如下所示: <uap:Capability Name="phoneCall" />
  • 应用程序有一个后台任务,用于绑定 PhoneCallOriginDataRequestTriggerDetails 触发器。
  • 应用程序可以在“设置> ”-“隐私> ”-“电话呼叫) ”下 (进行电话呼叫。

如果上述任一错误,SetCallOrigin 将返回拒绝访问错误。

应用程序由 PhoneCallOriginDataRequestTriggerDetails 触发时,应在后台调用此方法。

以下示例演示如何设置源的位置以响应触发器。

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();
    }
}

适用于