Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by BrodyDaChappy · Nov 13, 2016 at 09:06 PM · adsiapadvertisingremove

IAP Ads Removed Pref Error

HI All,

I have implemented IAP in my game to "RemoveAds", i used Unity IAP and the sample code (Below) this is not the full code but the section that requires the function, in my LevelManager script i have created bool set it to true and i check it before an ad is played, like so, PlayerPrefs.GetInt ("RemovedAds", 0) == 0) ..... the whole thing works, i send to alpha testers and they purchase the item but the ads still play, any ideas why?.

// Or ... a non-consumable product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // TODO: The non-consumable item has been successfully purchased, grant this item to the player. PlayerPrefs.SetInt("AdsRemoved", 1); PlayerPrefs.Save(); Debug.Log("Purchase Complete"); }

Comment
Add comment · Show 1
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 BrodyDaChappy · Nov 13, 2016 at 09:07 PM 0
Share
 #endif
 
         if (Advertisement.isSupported && !Advertisement.isInitialized && PlayerPrefs.GetInt("AdsRemoved", 0) == 0)
         {
             Advertisement.Initialize(gameId, enableTest$$anonymous$$ode);
         }
     }
     
     void ShowAd()
     {
         if (Advertisement.IsReady() && currentScene >= adInterval && currentScene % adInterval == 1 && PlayerPrefs.GetInt("AdsRemoved", 0) == 0)
         {
             Advertisement.Show();
         }
     }
     #endregion

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Naphier · Nov 14, 2016 at 10:41 PM

What's calling ShowAds? ShowAds should also be checking to see if that PlayerPref has been set.

Comment
Add comment · Show 4 · 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 BrodyDaChappy · Nov 20, 2016 at 08:00 PM 0
Share

Apologies @Naphier,

I have only just seen this, i will make some changes and give it a test, let you know soon as.

Thanks.

avatar image BrodyDaChappy · Nov 28, 2016 at 10:23 PM 0
Share

@Naphier, I have added the check before showing ads like so,

If (PlayerPrefs.GetInt("AdsRemoved" , 0) == 0) ShowAds();

The problem i am having is that now the ads in the game are not working, it is defiantly to do with the check in the ShowAds(); section because as soon as i remove this they work again, any ideas?

Cheers.

avatar image Naphier BrodyDaChappy · Nov 28, 2016 at 10:36 PM 0
Share

Sounds like you have that value set to 1 in the player prefs. Obviously, you'll need to reset the value to test. If the app is on a mobile device then clear the app data or uninstall and reinstall it. If it is in Windows then call PlayerPrefs.DeleteAll() and that will clear them out. To learn more about player prefs and data saving check out my blog (http://blog.naplandgames.com).

Beyond that try some more debugging.

Cheers!

avatar image BrodyDaChappy Naphier · Nov 29, 2016 at 12:57 PM 0
Share

@Naphier.

Thanks for the info i will see what i can do and let you know, the app is for mobile, Android and IOS, check it out if you like. :)

Changed a bit since the versions below, bug fixes and Design etc. I wont update until i have IAP added.

Check out my game https://play.google.com/store/apps/details?id=com.HappyChappyGames.Bounce_E Free on Google Play Store Now!!!

Now Available for IOS!! Check it out here!! https://itunes.apple.com/gb/app/bounce-e/id1161264369?mt=8

avatar image
0

Answer by BrodyDaChappy · Nov 30, 2016 at 09:08 PM

Hi @Naphier,

I have figured it out, i did an alpha test build of my latest changes and everything done as it should, but i do want to double check it with another tester who i am waiting for now.

Based on your answers/comments i figured out what i needed to try and it worked smoothly as it should :).

Adding a "Remove Ads" option took me a good month or so now, glad to finally be over it :).

Cheers.

Comment
Add comment · Show 1 · 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 BrodyDaChappy · Nov 30, 2016 at 09:16 PM 0
Share

Anyone else that would like to know how to integrate Unity IAP for "Remove Ads" feel free to e-mail me, e-mail should be on my profile.

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

79 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

can i apply an ad on a material 1 Answer

How do I lock down a level 0 Answers

How do I pause all game activity until unity ad ends 1 Answer

My unity adverts aren't working 0 Answers

Advertisement error when load new scene,Ads shows error when load scene 1 Answer


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