Use Donations
Donations let your users support you with in-app purchases, from inside your app. This is optional.
Step 1: Create your products
Section titled “Step 1: Create your products”In the Google Play Console, create one in-app product for each donation option, for example a small, a medium and a large donation. Write down each Product ID.
Step 2: Turn on billing
Section titled “Step 2: Turn on billing”Billing is on in the sample. Check these two things:
-
In
MainActivity.kt,billingEnabledistrue:override val billingEnabled = true -
In
app/src/main/AndroidManifest.xml, this line is there and isn’t commented out:<uses-permission android:name="com.android.vending.BILLING" />
Step 3: Add your license key
Section titled “Step 3: Add your license key”Donations need your app’s license key, even if you don’t use the license checker. See Change Security Settings.
Step 4: Add your products
Section titled “Step 4: Add your products”Open app/src/main/res/values/dashboard_setup.xml and add each Product ID as an item:
<string-array name="donation_items"> <item>small_donation</item> <item>medium_donation</item> <item>large_donation</item></string-array>The IDs must match the ones in the Play Console exactly.
Note
In-app purchases only work for builds installed from Google Play. Upload your app to a testing track (internal testing is the quickest) to try them.
Not using donations?
Section titled “Not using donations?”- Set
billingEnabledtofalseinMainActivity.kt. - Delete the
BILLINGpermission line fromAndroidManifest.xml. - Leave
donation_itemsempty.
Made by Jahir Fiquitiva. Questions? Ask in the Discord server.