在安卓游戏上工作,在应用内购买程序上停滞不前



我正在开发一款Android游戏。我被应用内购买程序卡住了。我决定使用Soomla Unity IAP插件。我试过他们的松饼样品程序,效果很好。但我不知道如果有人从我的游戏中购买了硬币(或任何好的),我怎么会知道。我在youtube上看到了一些视频,我浏览了SOOMLA的git hub页面,但没有发现任何可以消除我疑虑的东西。伙计们,请帮帮我,或者推荐你知道的任何有价值的材料。非常感谢。

您的问题不够具体,所以我将尝试解决几种方法:

首先,假设你是以真钱出售硬币(市场购买),你想使用SOOMLA的事件系统来处理事件。注册处理程序的一个常见事件是OnMarketPurchase,当用户使用Google Play、Apple App Store或亚马逊购买东西时,您将收到通知,具体取决于您的平台:

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上运行)也应该恢复用户以前的终身商品交易,在这种交易中,你还可以处理触发的事件,所以这是判断用户以前是否购买过东西的另一种方式(例如"删除广告")。

相关内容

最新更新