18
\$\begingroup\$

I would like to add a "no ads" service to my game such that ads can be removed with a single payment. How can I implement this correctly?

If I just save the fact that the service was paid for locally on the device, the user would have to pay again if they somehow erase the application's data.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ The second part of the question is too broad (I see Byte's already edited it out); the first part of the question is unclear. Are you asking if this is okay, morally or ethically? Or are you asking how to save the fact that the service has been paid for on the device? \$\endgroup\$
    – user1430
    Commented May 17, 2016 at 16:08
  • 1
    \$\begingroup\$ For now I'm just going to assume you're asking how, since that's the only remotely on-topic way to interpret the question. \$\endgroup\$
    – user1430
    Commented May 17, 2016 at 16:10

2 Answers 2

28
\$\begingroup\$

If you use Google Play's in-app purchase APIs to implement your 'disable ads' purchase, this is basically handled for you. You'll want to create a non-consumable product that users can purchase. Non-consumable products represent, essentially, a permanent benefit or unlock. Such purchases can be restored to wiped/clean/new phones by the user, so they'll never need to re-purchase the ad disable.

This page contains detailed instructions on integrating the IAP API with your game. The steps are, essentially:

  • Add the library to your project and update your manifest files.
  • Bind to IInAppBillingService via a service connection.
  • Send and receive the appropriate data to the service via that interface (getSkuDetails to get the list of available products, getBuyIntent to begin the purchase transaction, et cetera).

You'll also need to test, via getPurchases, to see if a user has purchased the 'disable ads' item (and if so, actually disable the ads).

You create the actual 'disable ads' purchasable item from your Google Play developer console.

\$\endgroup\$
4
  • \$\begingroup\$ So, wait, Google knows in advance whether an app has "consumable" IAPs or not? They should really reveal that in the store then; "has in-app purchases" could mean anything. \$\endgroup\$
    – Random832
    Commented May 17, 2016 at 19:50
  • 3
    \$\begingroup\$ @Random832 No, I don't think so. It only knows if a product is a subscription or not. You can send a "consumePurchase" request for any non-subscription product, it's not the product itself that is consumable. I guess they could in theory try to scan your binary and look for calls against that interface, but I doubt they bother. \$\endgroup\$
    – user1430
    Commented May 17, 2016 at 19:54
  • 1
    \$\begingroup\$ Maybe it's not a coincidence that IAP and API are anagrams of one another. \$\endgroup\$
    – ArtOfCode
    Commented May 18, 2016 at 21:05
  • \$\begingroup\$ I twist my own tongue trying to pronounce IAP API... \$\endgroup\$ Commented May 24, 2016 at 0:59
9
\$\begingroup\$

If you're not using Google Play's tools as in Josh's answer (although, I recommend you do use those tools). You'd have to manage this information yourself.

You would want to avoid storing something locally on the user's device. Users don't want to have to pay to remove ads per device or per install.

You need to maintain a database with users who have paid. Upon launch (every time, in case they purchase the ad removal on a different device), your application checks the database, if the user account is found, you'd disable the ads permanently for that installation. The user account information should be unique to the user, ideally the Google account they used to purchase the ad removal.

When a user purchases the ad removal, you'd add their account information to the database and disable their ads.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .