我正在迁移
- Windows 8.1 应用,它使用
Windows.ApplicationModel.Store
命名空间用于 IAP - 带有
Windows.Services.Store
命名空间的 Windows 10 UWP
为了确定应用内项目的许可状态,前者有一个 LicenseInformation
属性,而后者有一个 GetAppLicenseAsync()
方法。
因此,对于前者,有关 IAP 的信息(似乎是?)是即时的,而对于新方法,信息可能需要更长的时间。
我的问题:新概念真的更慢还是速度相同,新的异步方法只是反射(reflect)了获取信息从来都不是瞬时的事实?
我的应用需要在应用启动时就已购买的所有商品的信息。因此,我看到的唯一方法是在应用程序启动时调用 GetAppLicenseAsync()
并等待信息出现,然后再显示用户界面。
编辑 2017-07-25:
简而言之,我的问题是:GetAppLicenseAsync()
方法最多需要多长时间?
最佳答案
Is the newer concept really slower or is the speed the same and the new async method just reflects the fact that getting the information has never been instantaneous?
当您调用 GetAppLicenseAsync()
方法时,需要多长时间才能看到用户界面?
对我来说,新命名空间中的 API 是即时的。也许您的请求延迟可能与您的网络环境有关。但是,LicenseInfomation
的结果存储在本地,因此它可以是即时的,因为您可以离线获取信息。对于新命名空间,您还可以在用户首次购买该商品时将应用许可信息存储在本地存储中,这样您的应用启动过程就不会受到网络环境的影响。
此外,根据this document中的注释:
If your app targets Windows 10, version 1607, or later, we recommend that you use members of the
Windows.Services.Store
namespace instead of theWindows.ApplicationModel.Store
namespace. TheWindows.Services.Store
namespace supports the latest add-on types, such as Store-managed consumable add-ons, and is designed to be compatible with future types of products and features supported by Windows Dev Center and the Store. TheWindows.Services.Store
namespace is also designed to have better performance.
因此,将命名空间迁移到 Windows.Services.Store
是合适的。
关于c# - UWP - 应用内产品 - GetAppLicenseAsync() 的速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45245274/