productId | 所购买商品的 ID。 |
amount | 商品价格。 |
currency | 交易使用的货币的缩写,例如“USD”(美元)。请参阅 http://en.wikipedia.org/wiki/ISO_4217,查看标准化货币缩写列表。 |
receiptPurchaseData | 应用内购的收据数据 (iOS)/收据 ID (Android)/,用于向 Apple iTunes/Google Play 验证购买。如果缺少收据,则使用 null。 |
signature | Android 收据签名。如果使用原生 Android,请使用 INAPP_DATA_SIGNATURE 字符串,它包含了使用开发者私钥进行签名的购买数据的签名。该数据签名使用 RSASSA-PKCS1-v1_5 方案。如果缺少签名,则传入 null。 |
usingIAPService | 使用 UnityIAP 时设置为 true。 |
跟踪变现(可选)。
Unity Analytics 提供一种灵活方法来跟踪通过应用内购发生的变现事件。每次玩家触发变现事件时都应调用此方法。
Transaction 方法需要价格参数、货币和可选的 Apple iTunes/Google Play 收据字符串。
using System; using UnityEngine;
#if ENABLE_CLOUD_SERVICES_ANALYTICS using UnityEngine.Analytics;
public class GamePurchaseMonoBehaviour : MonoBehaviour { public void OnPurchase() { Analytics.Transaction("12345abcde", 0.99m, "USD", null, null); } } #endif
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.