在Android游戏上工作,坚持使用In app购买节目

时间:2015-02-18 18:09:10

标签: android plugins unity3d in-app-purchase soomla

我正在开发Android游戏。我陷入了在应用购买节目中的困境。 我决定使用Soomla Unity IAP插件。 我尝试了他们的松饼样本程序,效果很好。 但我不明白我怎么知道有人从我的游戏中购买了硬币(或任何好处)。 我在youtube上看过一些视频,我已经浏览了SOOMLA的git hub页面,但没有找到任何可以解决我怀疑的内容。 请帮助我,或者推荐你知道的任何有价值的材料。 谢谢!!

1 个答案:

答案 0 :(得分: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上运行)应该还恢复用户以前的终身商品交易,在这些交易中你也可以处理触发的事件,这是另一种方式告知用户以前是否购买了某些东西(例如“删除广告”)。