應用程式內建購買功能In-app purchases
HoloLens 中支援應用程式內購買,但有一些工作可以進行設定。In-app purchases are supported in HoloLens, but there's some work to set them up.
若要使用應用程式購買功能,您必須:To use the in app-purchase functionality, you must:
- 建立 XAML 2d 視圖 以顯示為平板Create a XAML 2D view to appear as a slate
- 切換至該位置以啟用放置,使其離開沉浸式視圖Switch to it to activate placement, which leaves the immersive view
- 呼叫 API: await CurrentApp. RequestProductPurchaseAsync ( "DurableItemIAPName" ) ;Call the API: await CurrentApp.RequestProductPurchaseAsync("DurableItemIAPName");
此 API 會顯示顯示應用程式內購買名稱、描述和價格的 stock Windows OS 快顯視窗。This API will bring up the stock Windows OS popup that shows the in-app purchase name, description, and price. 然後,使用者可以選擇購買選項。The user can then choose purchase options. 完成此動作之後,應用程式將需要顯示 UI,讓使用者能夠切換回其 沉浸式視圖。Once the action is completed, the app will need to present UI, which allows the user to switch back to its immersive view.
針對以桌面為基礎 Windows Mixed Reality 沉浸式耳機的應用程式,在呼叫 RequestProductPurchaseAsync API 之前,不需要手動切換至 XAML 視圖。For apps targeting desktop-based Windows Mixed Reality immersive headsets, it isn't required to manually switch to a XAML view before calling the RequestProductPurchaseAsync API.