Unity IAP 通过 SubscriptionManager
类支持商品订阅信息查询。如需示例代码,请查看 Unity IAP SDK 1.19+ 中包含的 IAPDemo.cs 脚本。
此类支持 Apple 商店和 Google Play 应用商店。对于 Google Play,此类仅支持使用 IAP SDK 1.19+ 购买的商品。
方法 | 描述 |
---|---|
public SubscriptionInfo getSubscriptionInfo() |
返回 SubscriptionInfo 对象(请参阅下文) |
SubscriptionInfo
类包含商品的订阅相关信息。
方法 | 描述 |
---|---|
public string getProductId() |
返回商品的商店 ID。 |
public DateTime getPurchaseDate() |
返回商品的购买日期。 对于 Apple,购买日期是订阅的购买或续订日期。对于 Google,购买日期是订阅的原始购买日期。 |
public Result isSubscribed() |
返回 Result 枚举以指示当前是否已订阅此商品。Apple 商店中不可续订的商品返回 Result.Unsupported 值。Apple 商店中可自动续订的商品以及 Google Play 应用商店中的订阅商品返回 Result.True 或 Result.False 值。 |
public Result isExpired() |
返回 Result 枚举以指示此商品是否已到期。 * Apple 商店中不可续订的商品返回 Result.Unsupported 值。* Apple 商店中可自动续订的商品以及 Google Play 应用商店中的订阅商品返回 Result.True 或 Result.False 值。 |
public Result isCancelled() |
返回 Result 枚举以指示是否已取消此商品。取消的订阅意味着商品目前为已订阅状态,但不会在下一个账单日期续订。Apple 商店中不可续订的商品返回 Result.Unsupported 值。Apple 商店中可自动续订的商品以及 Google Play 应用商店中的订阅商品返回 Result.True 或 Result.False 值。 |
public Result isFreeTrial() |
返回 Result 枚举以指示此商品是否为免费试用商品。* 如果应用程序不支持 Android 版本 6+ 的应用内计费 API,则 Google Play 应用商店中的商品会返回 Result.Unsupported。 Apple 商店中不可续订的商品返回 Result.Unsupported 值。Apple 商店中可自动续订的商品以及 Google Play 应用商店中的订阅商品返回 Result.True 或 Result.False 值。 |
public Result isAutoRenewing() |
返回 Result 枚举以指示此商品是否为可自动续订的商品。Apple 商店中不可续订的商品返回 Result.Unsupported 值。Apple 商店中可自动续订的商品以及 Google Play 应用商店中的订阅商品返回 Result.True 或 Result.False 值。 |
public TimeSpan getRemainingTime() |
返回 TimeSpan 以指示在下一个账单日期之前剩余的时间。如果应用程序不支持 Android 版本 6+ 的应用内计费 API,则 Google Play 应用商店中的商品会返回 TimeSpan.MaxValue 。 |
public Result isIntroductoryPricePeriod() |
返回 Result 枚举以指示此商品是否处于试销价格期间。Apple 商店中不可续订的商品返回 Result.Unsupported 值。Apple 商店中可自动续订的商品以及 Google Play 应用商店中的订阅商品返回 Result.True 或 Result.False 值。Google Play 应用商店中的商品返回 Result 结果。如果应用程序不支持 Android 版本 6+ 的应用内计费 API,则不支持。 |
public TimeSpan getIntroductoryPricePeriod() |
返回 TimeSpan 以指示试销价格期间的剩余时间。没有试销价格期的订阅商品返回 TimeSpan.Zero 。如果应用程序不支持 iOS 版本 11.2+、macOS 10.13.2+ 或 tvOS 11.2+,则 Apple 商店中的商品会返回 TimeSpan.Zero。 |
public long getIntroductoryPricePeriodCycles() |
返回可应用于此商品的试销价格期间的数量。 如果应用程序不支持 iOS 版本 11.2+、macOS 10.13.2+ 或 tvOS 11.2+,则 Apple 商店中的商品会返回 0。 |
public string getIntroductoryPrice() |
返回一个字符串以指示商品的试销价格。 没有试销价格的商品会返回 "not available" 值。具有试销价格的 Apple 商店商品会返回格式为 "0.99USD" 的值。具有试销价格的 Google Play 商品会返回格式为 "$0.99" 的值。如果应用程序不支持 iOS 版本 11.2+、macOS 10.13.2+ 或 tvOS 11.2+,则 Apple 商店中的商品会返回 "not available" 。 |
public DateTime getExpireDate() |
返回商品下次自动续订或到期(如果订阅已取消自动续订)的日期。 如果应用程序不支持 Android 版本 6+ 的应用内计费 API,则 Google Play 应用商店中的商品会返回 TimeSpan.MaxValue。 |
2018–05–30 页面已发布
在 2018.1 版中添加了订阅商品支持 NewIn20181
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.