PhoneCallOriginManager.SetCallOrigin(Guid, PhoneCallOrigin) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
設定通話傳入時的通話來源。
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
此通話的唯一識別碼。 這會從PhoneCallOriginDataRequestTriggerDetails的targetId擷取
- callOrigin
- PhoneCallOrigin
來電的通話資訊。
- 屬性
Windows 需求
應用程式功能 |
phoneCallHistory
phoneCallHistorySystem
|
備註
嘗試呼叫此方法之前,請確定下列事項。
- 您可以在應用程式資訊清單檔案中宣告 PhoneCall 功能,如下所示:
<uap:Capability Name="phoneCall" />
- 您的應用程式具有系結 PhoneCallOriginDataRequestTriggerDetails 觸發程式的背景工作。
- 您的應用程式可以在 [設定 - 隱私權 - > 電話] 底 > 下 (撥打電話) 。
如果其中任何一項不是 true,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();
}
}