我正在开发一款安卓游戏。我被困在应用内购买编程中。我决定使用 Soomla Unity IAP 插件。我尝试了他们的松饼示例程序,效果很好。但我不知道我怎么知道有人从我的游戏中购买了硬币(或任何好东西)。我在 youtube 上看过一些视频,我浏览了 SOOMLA 的 git hub 页面,但没有找到任何可以消除我疑惑的东西。请帮帮我或者参考任何你知道的有价值的材料。谢谢 !!
1 回答
3
您的问题不够具体,因此我将尝试解决几种方法:
首先,假设您以真钱出售硬币(市场购买),您希望使用 SOOMLA 的事件系统在事件发送时处理事件。注册处理程序的常见事件是OnMarketPurchase
,当用户使用 Google Play、Apple App Store 或 Amazon 购买商品时,您会收到通知,具体取决于您的平台:
StoreEvents.OnMarketPurchase += onMarketPurchase;
public void onMarketPurchase(PurchasableVirtualItem pvi, string payload,
Dictionary<string, string> extra) {
// pvi - the PurchasableVirtualItem that was just purchased
// payload - a text that you can give when you initiate the purchase operation and
// you want to receive back upon completion
// extra - contains platform specific information about the market purchase
// Android: The "extra" dictionary will contain "orderId" and "purchaseToken"
// iOS: The "extra" dictionary will contain "receipt" and "token"
// ... your game specific implementation here ...
}
其次,您可以使用StoreInventory
该类来查询用户的库存,从而了解他\她的余额以及他们购买了什么:
StoreInventory.GetItemBalance("currency_coins");
第三 - 该方法SoomlaStore.RefreshInventory
(默认在 Android 版本上运行,但不是在 iOS 上运行)还应该全部恢复用户以前的终身商品交易,您还可以在其中处理触发事件,因此这是判断用户之前是否购买过的另一种方式某些东西(例如“删除广告”)。
于 2015-02-19T18:20:28.643 回答