Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by khos85 · Jul 29, 2014 at 10:24 PM · androidgameadsremove

how to design a "remove ads" option in android unity game?

Hi,

how to design a "remove ads" option in android unity game? I have been searching but cannot see any sample code, does anyone have any advise on how to do this?

Thanks, Kim

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by keburanuil · Jul 29, 2014 at 11:59 PM

I did it in my game simple by using playerprefs. If player buys/uses "remove ads"-option, save it in playerprefs and destroy all ad-objects and events. Every time you start the game, check if player has the adfree version and if player has then don't setup ads.

 function Awake()
 {
     SetupAds();
 }
 
 function SetupAds()
 {
     if(PlayerPrefs.HasKey("AdFree"))
         return;
 
     // Setup your ads here
 }
 
 function RemoveAds()
 {
     if (PlayerPrefs.HasKey("AdFree"))
         print("Ads already removed");
     else{
         PlayerPrefs.SetInt("AdFree", 1);
         PlayerPrefs.Save();
 
         // destroy/disable all your ad objects here
     }
 }
 
 function RestorePurchases()
 {
     if (IsProductPurchased("ProductId"))
         RemoveAds();
 }

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vitor_r · Jul 30, 2014 at 04:16 AM 0
Share

But if the player clear the application data, the player prefs will be lost. And the Ads will appear again. I would advise to store this information somewhere else and make a "restore purchase" option just in case :)

avatar image khos85 · Jul 30, 2014 at 05:37 AM 0
Share

Thanks for the great feedback, @ agoVitor_r , where eklse could you store this data? on a DB of your own, remotely?

avatar image keburanuil · Jul 30, 2014 at 12:11 PM 0
Share

If you use google's in-app purchasing, google stores your every purchase.

http://forum.unity3d.com/threads/released-android-native-plugin.201468/

In this plugin you can simply check every purchase using method:

 public bool IsProductPurchased(string S$$anonymous$$U)
 

So you would create a restore purchase button and then check if the product is bought.

avatar image khos85 · Jul 30, 2014 at 10:29 PM 0
Share

I purchased the asset on http://forum.unity3d.com/threads/released-android-native-plugin.201468/ , but it seems like a lot is going on there, could I ask how would you use: public bool IsProductPurchased(string S$$anonymous$$U) in the sample script that given earlier? Any help would be much appreciated, it would be nice as it is a nice a simple piece of code but I do not understand the IsProductPurchased(string S$$anonymous$$U) yet, how to use, what does it do?

Thanks for any help provided.

avatar image keburanuil · Jul 31, 2014 at 02:11 PM 0
Share

Actually you have to do your billing/ad -manager in c#. $$anonymous$$y script was just a simulation how I desinged my "remove ads"-option.

However if you use js, you can make one c# script that has methods like RestorePurchases() and call them from js using Send$$anonymous$$essage().

     // This should print false unless you have purchased product: "abc123"
     print(AndroidInAppPurchase$$anonymous$$anager.instance.inventory.IsProductPurchased("abc123")); 

Your billing manager would look like this:

 public class Example : $$anonymous$$onoBehaviour{
     
     // Add all methods you need.
     // Call methods from js using Send$$anonymous$$essage().
 
     public void RestorePurchases()
     {
         if (AndroidInAppPurchase$$anonymous$$anager.instance.inventory.IsProductPurchased("abcd12345"))
             // Remove ads
     }
 }


Read this for more information: https://docs.google.com/document/d/1px0BVXcZqgrW99OQV4b$$anonymous$$7q1rD5NYaCYTxXnn4eS4ytY/edit#

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Admob works on an empty project but not on my actual project 0 Answers

Making Money with Unity Ads 1 Answer

can you please write rewarded ad script 0 Answers

Vungle Ads Not Showing For One Specific Package Name 0 Answers

Android Ads Error 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges