Hi guys, i have been successfully able to integrate AdMob ads on the app that i am developing. I have a banner ad on homepage and also an interstitial ad that shows on gameover. The ads are controlled through a C# Script. I have also installed IAP services on unity and also successfully followed their tutorial to create an IAP to remove ads. Now my question is, what should i call on the line below to actually remove the ads after a player purchases that non consumable item? My understanding is that at the moment it just shows a debug text that Ads are Removed, but it needs the actual code, function to really remove ads. Anyone can help with this?
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
if (String.Equals(args.purchasedProduct.definition.id, removeAds, StringComparison.Ordinal))
{
Debug.Log(“Remove All Ads”);
}
else
{
Debug.Log(“Purchase Failed”);
}
return PurchaseProcessingResult.Complete;
}
Have a bool… if not purchased show ad and when they buy it just set it to true
Thankn you for your suggestion. I am kinda new to c#, almost 2 weeks now, can you show me how can i implement the bool function there?
I am attaching here the 2 scripts for reference. the Admanager runs the ad (which i have tested and they run like they are suppose to). The IAPManager is where i have the code and where i need to turn of all ads after that product remove ads is purchased.
6208656–682059–Admanager.cs (1.61 KB)
6208656–682062–IAPManager.cs (4.16 KB)
I’m on my phone so I cant open the file on the phone
but yeah when you show ad when you use if statement with the conditions just add && bool
I understand. A little help with the code would be appreciated. I am afraid if i use the bool method, when the player closes the game and opens it again, the ads will show again. I need a method that the ads are gone forever after the player purchases the non consumable remove ads product.
- [quote=“dmarku26, post:7, topic: 804705”]
I understand. A little help with the code would be appreciated. I am afraid if i use the bool method, when the player closes the game and opens it again, the ads will show again. I need a method that the ads are gone forever after the player purchases the non consumable remove ads product.
[/quote]
You could just save the value…either with json or binary or playerprefs
if(playtime %5 == 0 && !purchased)
{
ShowAd();
}
When player buy remove ad when you set purchased to true save the value and every time game start read the value from save then you will have your results
I could not make it work but thank you