透過 Microsoft Store Services SDK 與客戶互動Engage customers with the Microsoft Store Services SDK

Microsoft Store Services SDK 提供的功能可協助您在通用 Windows 平臺 (UWP) 應用程式中與客戶互動,例如將目標通知傳送至您的應用程式,並在您的應用程式中執行 A/B 實驗。The Microsoft Store Services SDK provides features that help you engage with customers in your Universal Windows Platform (UWP) apps, such as sending targeted notifications to your apps and running A/B experiments in your apps. 此 SDK 是適用於 Visual Studio 2015 及後續 Visual Studio 版本的擴充功能。This SDK is an extension for Visual Studio 2015 and later versions of Visual Studio.

注意

若要在您的 UWP app 中顯示廣告,請使用 Microsoft Advertising SDK 而非 Microsoft Store Services SDK。To display ads in your UWP apps, use the Microsoft Advertising SDK instead of the Microsoft Store Services SDK. Advertising 程式庫已從 Microsoft Store Services SDK 移至 Microsoft Advertising SDK。The advertising libraries have been moved from the Microsoft Store Services SDK to the Microsoft Advertising SDK. 如需詳細資訊,請參閱在您的應用程式中顯示廣告For more information, see Display ads in your app.

Microsoft Store Services SDK 支援的案例Scenarios supported by the Microsoft Store Services SDK

Microsoft Store Services SDK 目前支援下列 UWP app 案例。The Microsoft Store Services SDK currently supports the following scenarios for UWP apps. 如需 API 參考文件,請參閱 Microsoft Store Services SDK API 參考For API reference documentation, see Microsoft Store Services SDK API reference.

案例Scenario 描述Description
在您的 UWP app 中使用 A/B 測試來執行實驗Run experiments in your UWP app with A/B testing 在「通用 Windows 平台」(UWP) app 中執行 A/B 測試,以在將功能釋出給每個人之前,先對部分客戶測量功能是否有效。Run A/B tests in your Universal Windows Platform (UWP) app to measure the effectiveness of features on some customers before you release the features to everyone. 在合作夥伴中心中定義實驗之後,請使用 StoreServicesExperimentVariation 類別,在您的應用程式中取得實驗的變化、使用此資料修改您正在測試之功能的行為,然後使用 LogForVariation 方法將 view 事件和轉換事件傳送至合作夥伴中心。After you define an experiment in Partner Center, use the StoreServicesExperimentVariation class to get variations for your experiment in your app, use this data to modify the behavior of the feature you are testing, and then use the LogForVariation method to send view event and conversion events to Partner Center. 最後,使用合作夥伴中心來查看結果及管理實驗。Finally, use Partner Center to view the results and manage the experiment.
從您的 UWP app 啟動意見反應中樞Launch Feedback Hub from your UWP app 在您的 UWP app 中使用 StoreServicesFeedbackLauncher 類別將您的 Windows 10 客戶引導至「意見反應中樞」,以便他們在其中提交問題、建議及附議。Use the StoreServicesFeedbackLauncher class in your UWP app to direct your Windows 10 customers to Feedback Hub, where they can submit problems, suggestions, and upvotes. 然後,在「合作夥伴中心」的意見反應報告中管理此意見反應。Then, manage this feedback in the Feedback report in Partner Center.
設定您的 UWP 應用程式以接收合作夥伴中心推播通知Configure your UWP app to receive Partner Center push notifications 使用 UWP 應用程式中的 StoreServicesEngagementManager 類別,註冊您的應用程式,以接收使用合作夥伴中心傳送給客戶的目標推播通知。Use the StoreServicesEngagementManager class in your UWP app to register your app to receive targeted push notifications that you send to your customers using Partner Center.
記錄 UWP 應用程式中的自訂事件,以取得合作夥伴中心中的使用量報表Log custom events in your UWP app for the Usage report in Partner Center 在您的 UWP 應用程式中使用 StoreServicesCustomEventLogger 類別,以記錄與合作夥伴中心中的應用程式相關聯的自訂事件。Use the StoreServicesCustomEventLogger class in your UWP app to log custom events that are associated with your app in Partner Center. 然後,在合作夥伴中心的 [使用方式] 報表的 [ 自訂事件 ] 區段中,查看您自訂事件的總發生次數。Then, review the total occurrences for your custom events in the Custom events section of the Usage report in Partner Center.

PrerequisitesPrerequisites

Microsoft Store Services SDK 需要:The Microsoft Store Services SDK requires:

  • Visual Studio 2015 或更新版本。Visual Studio 2015 or a later version.
  • 與您的 Visual Studio 版本一起安裝的 Visual Studio Tools for Universal Windows Apps。Visual Studio Tools for Universal Windows Apps installed with your version of Visual Studio.

安裝 SDKInstall the SDK

在開發電腦上安裝 Microsoft Store Services SDK 有兩個選項:There are two options for installing the Microsoft Store Services SDK on your development computer:

  • MSI 安裝程式    您可以透過 此處提供的 MSI 安裝程式來安裝 SDK。MSI installer  You can install the SDK via the MSI installer available here.
  • NuGet 套件    您可以將 SDK 安裝為 NuGet 套件。NuGet package  You can install the SDK as a NuGet package.

Microsoft 會定期發行具有效能改進與新功能的新版 Microsoft Store Services SDK。Microsoft periodically releases new versions of the Microsoft Store Services SDK with performance improvements and new features. 如果您現有的專案使用此 SDK,而您想要使用最新的版本,則您只需在開發電腦上下載並安裝最新版的 SDK 即可。If you have existing projects that use the SDK and you want to use the latest version, download and install the latest version of the SDK on your development computer.

透過 MSI 安裝Install via MSI

透過 MSI 安裝程式安裝 Microsoft Store Services SDK:To install the Microsoft Store Services SDK via the MSI installer:

  1. 關閉所有 Visual Studio 執行個體。Close all instances of Visual Studio.

  2. 如果您先前已安裝 Microsoft Store Engagement and Monetization SDK、通用廣告用戶端 SDK 或 Ad Mediator 擴充功能,請立即將這些 SDK 解除安裝。If you previously installed the Microsoft Store Engagement and Monetization SDK, Universal Ad Client SDK, or Ad Mediator extension, uninstall these SDKs now. 您也可以開啟 [命令提示字元] 視窗,然後執行下列命令,以清除可能已與 Visual Studio 一起安裝但未出現在電腦上已安裝程式清單中的任何舊 SDK 版本:Optionally, open a Command Prompt window and run these commands to clean out any older SDK versions that may have been installed with Visual Studio, but which may not appear in the list of installed programs on your computer:

    MsiExec.exe /x{5C87A4DB-31C7-465E-9356-71B485B69EC8}
    MsiExec.exe /x{6AB13C21-C3EC-46E1-8009-6FD5EBEE515B}
    MsiExec.exe /x{6AC81125-8485-463D-9352-3F35A2508C11}
    
  3. 下載並安裝 Microsoft Store Services SDKDownload and install the Microsoft Store Services SDK. 可能需要幾分鐘的時間來安裝。It may take a few minutes to install. 請務必等到程序完成為止。Be sure and wait until the process has finished.

  4. 重新啟動 Visual Studio。Restart Visual Studio.

  5. 如果您現有的專案參考來自任何舊版 Microsoft Store Services SDK, Microsoft Advertising SDK、Universal Ad Client SDK 或 Microsoft Store Engagement and Monetization SDK 的程式庫,建議您在 Visual Studio 中開啟您的專案,然後清除並重建您的專案 (在 [方案總管] 中您的專案節點上按一下滑鼠右鍵並選擇 [清除] ,然後在您的專案節點上再次按一下滑鼠右鍵並選擇 [重建] )。If you have an existing project that references libraries from any earlier version of the Microsoft Store Services SDK, Microsoft Advertising SDK, Universal Ad Client SDK, or Microsoft Store Engagement and Monetization SDK, we recommend that you open your project in Visual Studio and clean and rebuild your project (in Solution Explorer , right-click your project node and choose Clean , and then right-click your project node again and choose Rebuild ).

否則,如果您是第一次在專案中使用 SDK,您現在便已準備好將組件參考新增至專案Otherwise, if you are using the SDK for the first time in your project, you are now ready to add the assembly reference to your project.

透過 NuGet 安裝Install via NuGet

透過 NuGet 安裝 Microsoft Store Services SDK 程式庫:To install the Microsoft Store Services SDK libraries via NuGet:

  1. 關閉所有 Visual Studio 執行個體。Close all instances of Visual Studio.

  2. 如果您先前已安裝 Microsoft Store Engagement and Monetization SDK、通用廣告用戶端 SDK 或 Ad Mediator 擴充功能,請立即將這些 SDK 解除安裝。If you previously installed the Microsoft Store Engagement and Monetization SDK, Universal Ad Client SDK, or Ad Mediator extension, uninstall these SDKs now. 您也可以開啟 [命令提示字元] 視窗,然後執行下列命令,以清除可能已與 Visual Studio 一起安裝但未出現在電腦上已安裝程式清單中的任何舊 SDK 版本:Optionally, open a Command Prompt window and run these commands to clean out any older SDK versions that may have been installed with Visual Studio, but which may not appear in the list of installed programs on your computer:

    MsiExec.exe /x{5C87A4DB-31C7-465E-9356-71B485B69EC8}
    MsiExec.exe /x{6AB13C21-C3EC-46E1-8009-6FD5EBEE515B}
    MsiExec.exe /x{6AC81125-8485-463D-9352-3F35A2508C11}
    
  3. 啟動 Visual Studio,然後開啟您要在其中使用 Microsoft Store Services SDK 的專案。Start Visual Studio and open the project in which you want to use the Microsoft Store Services SDK.

    注意

    如果您的專案已經包含來自先前 MSI 安裝之 SDK 的程式庫參考,請從您的專案中移除這些參考。If your project already includes library references from an earlier MSI installation of the SDK, remove these references from your project. 這些參考的旁邊將會有警告圖示,因為在先前的步驟中已移除它們所參考的程式庫。These references will have warning icons next to them because the libraries they reference were removed in the previous steps.

  4. 在 Visual Studio 中,按一下 [專案] 和 [管理 NuGet 套件] 。In Visual Studio, click Project and Manage NuGet Packages .

  5. 在搜尋方塊中,輸入 Microsoft.Services.Store.Engagement 並安裝 Microsoft.Services.Store.Engagement 套件。In the search box, type Microsoft.Services.Store.Engagement and install the Microsoft.Services.Store.Engagement package. 套件完成安裝後,儲存您的方案。When the package is done installing, save your solution.

    注意

    如果 [輸出] 視窗回報 Install-Package 錯誤,指出指定的路徑太長,您可能需要設定讓 NuGet 將套件解壓縮至路徑比預設位置短的替代位置。If the Output window reports an Install-Package error that indicates the specified path is too long, you may need to configure NuGet to extract packages to an alternate location with a shorter path than the default location. 若要這樣做,請將 repositoryPath 值新增到您電腦上的 nuget.config 檔案中,然後將它指派至可解壓縮 NuGet 套件的較短資料夾路徑。To do this, add the repositoryPath value to a nuget.config file on your computer and assign it to a short folder path where NuGet packages can be extracted. 如需詳細資訊,請參閱 NuGet 文件中的這篇文章For more information, see this article in the NuGet documentation. 或者,您也可以嘗試將您的 Visual Studio 專案移至路徑較短的替代資料夾。Alternatively, you can try moving your Visual Studio project to an alternate folder with a shorter path. 問題的原因也可能是您的全域套件路徑太長。The problem could also be caused by your global packages path being too long. 在此情況下,請將 globalPackagesFolder 值新增至您的 nuget.config 檔案。In this case, add the globalPackagesFolder value into your nuget.config file.

  6. 關閉包含您專案的 Visual Studio 方案,然後重新開啟方案。Close the Visual Studio solution that contains your project and then reopen the solution.

  7. 如果您的專案已參考舊版 Microsoft Store Services SDK 的程式庫,而且您已將專案更新為較新版本的 SDK,建議您在 方案總管 中清除並重建 (專案,並以滑鼠右鍵按一下專案節點,然後選擇 [ 清除 ],然後再以滑鼠右鍵按一下專案節點,然後選擇 [ 重建 ) ]。If your project already references libraries from an earlier version of the Microsoft Store Services SDK that was installed via NuGet and you have updated your project to a newer release of the SDK, we recommend that you clean and rebuild your project (in Solution Explorer , right-click your project node and choose Clean , and then right-click your project node again and choose Rebuild ).

否則,如果您是第一次在專案中使用 SDK,您現在便已準備好將組件參考新增至專案Otherwise, if you are using the SDK for the first time in your project, you are now ready to add the assembly reference to your project.

將組件參考新增至專案Add the assembly reference to your project

透過 MSI 安裝程式或 NuGet 安裝 Microsoft Store Services SDK 之後,請依照下列指示在您的 UWP 專案中參考 SDK 組件。After you install the Microsoft Store Services SDK via the MSI installer or NuGet, follow these instructions to reference the SDK assembly in your UWP project.

  1. 在 Visual Studio 中,開啟您的專案。Open your project in Visual Studio.

    注意

    如果您的專案是以 任何 CPU 為目標的 JavaScript App,請將您的專案更新成使用架構特定的建置輸出 (例如 x86 )。If your project is a JavaScript app that targets Any CPU , update your project to use an architecture-specific build output (for example, x86 ).

  2. 方案總管 中,以滑鼠右鍵按一下 [ 參考 ],然後選取 [ 加入參考 ]。In Solution Explorer , right click References and select Add Reference…

  3. [參考管理員] 中,展開 [通用 Windows] 、按一下 [擴充功能] ,然後選取 [Microsoft Engagement Framework] 旁邊的核取方塊。In Reference Manager , expand Universal Windows , click Extensions , and then select the check box next to Microsoft Engagement Framework . 這可讓您使用 Microsoft.Services.Store.Engagement 命名空間中的 API。This enables you to use the APIs in the Microsoft.Services.Store.Engagement namespace.

  4. 按一下 [確定]。Click OK .

注意

如果您已透過 NuGet 安裝 SDK 程式庫,您的專案將會包含 Microsoft.Services.Store.Engagement 參考。If you installed the SDK libraries via NuGet, your project will contain a Microsoft.Services.Store.Engagement reference. Microsoft.Services.Store.Engagement 參考代表 NuGet 套件 (而不是它當中的程式庫),您可以忽略它。The Microsoft.Services.Store.Engagement reference represents the NuGet package (rather than the libraries in it), and you can ignore it.

了解 SDK 中的架構套件Understanding framework packages in the SDK

Microsoft Store Services SDK 中的 Microsoft.Services.Store.Engagement.dll 程式庫設定為 架構套件The Microsoft.Services.Store.Engagement.dll library in the Microsoft Store Services SDK is configured as a framework package . 這個程式庫包含 Microsoft.Services.Store.Engagement 命名空間中的 API。This library contains the APIs in the Microsoft.Services.Store.Engagement namespace.

因為這個程式庫是架構套件,這意謂著在使用者安裝使用這個程式庫的 App 版本之後,每當我們發佈具有修正程式和效能改進的新程式庫版本時,便會在其裝置上透過 Windows Update 自動更新這個程式庫。Because this library is a framework package, this means that after a user installs a version of your app that uses this library, this library is automatically updated on their device through Windows Update whenever we publish a new version of the library with fixes and performance improvements. 這有助於確保您客戶的裝置上一律會安裝最新的可用程式庫版本。This helps to ensure that your customers always have the latest available version of the library installed on their devices.

如果我們發行的新版 SDK 在這個程式庫中引進新的 API 或功能,您將必須安裝最新版的 SDK 才能使用這些功能。If we release a new version of the SDK that introduces new APIs or features in this library, you will need to install the latest version of the SDK to use those features. 在此情況下,您也需要將已更新的 App 發佈到「Microsoft Store」。In this scenario, you would also need to publish your updated app to the Store.