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:
This is the price when I build the app to Google Play and run the app.
It is suppose to be $1.99.
Am I missing a step?
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With