How to get price from AdMob in Unity AIP?

I'm trying to get app purchase price (IAP) with Unity and AdMob ads.

public void InitializePurchasing() { // If we have already connected to Purchasing ... if (IsInitialized()) { // ... we are done here. return; } var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); builder.AddProduct(PRODUCT_REMOVE_ADS, ProductType.NonConsumable); UnityPurchasing.Initialize(this, builder); removeAdsPriceText.text = m_StoreController.products.WithID("removeads").metadata.localizedPrice.ToString(); // This should be the code to get the price } 

The price in the editor when I click on the game: enter image description here

This is the price when I create the application on Google Play and launch the application. enter image description here

Suppose it is $ 1.99. enter image description here

Am I missing a step?

+5
source share
1 answer

I finally understood the solution

The code needs to be called OnInitialized

 public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { m_StoreController = controller; m_StoreExtensionProvider = extensions; removeAdsPriceText.text = m_StoreController.products.WithID("removeads").metadata.localizedPriceString; } 

Thank you all for your help!

+4
source

Source: https://habr.com/ru/post/1261814/


All Articles