다음을 통해 공유


ToastOcclusionManagerPreview.SetToastWindowMargin(WindowId, Double) 메서드

정의

지정된 창에서 콘텐츠를 차단하지 않도록 OS에서 지정된 세로 오프셋을 사용하여 앱 알림을 보기 픽셀 단위로 표시하도록 요청합니다.

중요

ToastOcclusionManagerPreview.SetToastWindowMargin API는 제한된 액세스 기능의 일부입니다(LimitedAccessFeatures 클래스 참조). 자세한 내용을 확인하거나 잠금 해제 토큰을 요청하려면 LAF 액세스 토큰 요청 양식을 사용하세요.

public:
 static void SetToastWindowMargin(WindowId appWindowId, double margin);
 static void SetToastWindowMargin(WindowId const& appWindowId, double const& margin);
public static void SetToastWindowMargin(WindowId appWindowId, double margin);
function setToastWindowMargin(appWindowId, margin)
Public Shared Sub SetToastWindowMargin (appWindowId As WindowId, margin As Double)

매개 변수

appWindowId
WindowId

알림 오프셋 요청과 연결된 창의 WindowId 입니다. 오프셋을 적용하려면 주 화면에서 지정된 창을 포커스로 최대화해야 하며 화면 키보드는 표시되지 않아야 합니다.

margin
Double

double

앱 알림이 표시되는 세로 오프셋(보기 픽셀)입니다. 여백의 현재 최대값은 180픽셀입니다. 180픽셀보다 큰 여백에 대한 요청은 성공하지만 180픽셀로 고정됩니다. 음수 값을 지정하면 0으로 고정됩니다.

설명

이 API는 엔터프라이즈 고객이 기능을 테스트할 수 있도록 미리 보기로 릴리스되고 있습니다. 이 API는 향후 릴리스에서 제거 및/또는 수정될 가능성이 높습니다. API를 사용하기 전에 앱은 LimitedAccessFeatures.TryUnlockFeature를 호출하여 Microsoft에서 제공하는 기능 ID 및 앱 토큰을 전달하여 앱이 API를 사용할 권한이 있는지 확인해야 합니다. 권한 없는 앱의 호출은 영향을 주지 않습니다.

다음 예제 코드에서는 호출 앱에 대해 SetToastWindowMargin의 가용성을 검사 API를 호출하여 앱 알림을 90픽셀까지 이동하도록 요청하는 방법을 보여 줍니다. 이러한 호출은 앱 시작 중에 수행해야 합니다.

// App.xaml.cpp

static Platform::String^ FeatureName = L"com.microsoft.windows.ui.notifications.preview.toastOcclusionManagerPreview";
static Platform::String^ ApiToken = L"[API token]";
static Platform::String^ ApiAttestation = L"[Package family name] has registered their use of com.microsoft.windows.ui.notifications.preview.toastOcclusionManagerPreview with Microsoft and agrees to the terms of use.";


App::App()
{
    InitializeComponent();
    Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);

    m_isToastOcclusionManagerPreviewAvailable = DetectToastOcclusionManagerPreview();
}

bool App::DetectToastOcclusionManagerPreview()
{
    LimitedAccessFeatureRequestResult^ result = LimitedAccessFeatures::TryUnlockFeature(FeatureName, ApiToken, ApiAttestation);
    switch (result->Status)
    {
    case LimitedAccessFeatureStatus::Available:
    case LimitedAccessFeatureStatus::AvailableWithoutToken:
        return true;
    }
    return false;
}

void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
{
    ...

    // Request for toast window to be shifted up 90 pixels
    // Toasts will only be shifted up if the window is maximized,
    // on the primary screen and the software keyboard isn't present. 
    if (!m_isRegistered && m_isToastOcclusionManagerPreviewAvailable)
    {
        HWND window;

        IInspectable* inspectable = reinterpret_cast<IInspectable*>(CoreWindow::GetForCurrentThread());

        winrt::com_ptr<ICoreWindowInterop> interop;

        if (SUCCEEDED(inspectable->QueryInterface(IID_PPV_ARGS(&interop))) && SUCCEEDED(interop->get_WindowHandle(&window)))
        {
            // Get the windowId
            winrt::Windows::UI::WindowId windowId{ reinterpret_cast<uint64_t>(window) };

            ToastOcclusionManagerPreview::SetToastWindowMargin(windowId, 90);
        }

        m_isRegistered = true;
    }
}

적용 대상

추가 정보