Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the price from AdMob in Unity AIP?

Tags:

I am trying to pull in the price for In App Purchases (IAP) using Unity Ads and AdMob.

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
}

Price in the Editor when I hit play: enter image description here

This is the price when I build the app to Google Play and run the app. enter image description here

It is suppose to be $1.99. enter image description here

Am I missing a step?

like image 327
Tim Cooley Avatar asked Dec 24 '16 03:12

Tim Cooley


1 Answers

I finally figured out 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;
}

Thanks everyone for the help!

like image 156
Tim Cooley Avatar answered Sep 25 '22 16:09

Tim Cooley