Part 5 ended with version 1.5.1 in Play review. Before that release even went live, I decided I didn't want its biggest annoyance anymore: an ad every time the app opened.
A workout tracker is opened between sets, with chalk on your hands and a timer running. An interstitial at that moment isn't a business model, it's friction. So version 1.6.0 removes every forced ad and replaces them with three things you choose:
- Pro for life, a one-time purchase.
- Pro hours: watch one optional ad, get one hour of Pro.
- Tips: a pre-workout shot, a protein scoop or a creatine tub. They say thanks and add a Supporter badge, nothing else.
DotShredzilla is an Android workout tracker from FreeRave (DotSuite), written in Kotlin with Jetpack Compose and Firebase, and open source under Apache License 2.0: github.com/kareem2099/Shredzilla.
Deciding what Pro is
The hardest part wasn't code. It was drawing the line between free and Pro without making the free app feel crippled.
The rule I settled on: everything you need to train stays free. Logging, lists, programs, workout mode, supersets, the rest timer, the plate calculator, personal records, streaks, deload reminders, measurements, history and sharing.
Pro is the layer that interprets your data:
- The next-set coach and the "+2 reps" comparison with last session.
- Body-measurement insights and trend charts.
- A new stats screen: hard sets per muscle each week against the usual 10 to 20, an estimated 1RM trend per exercise, and eight weeks of sets, volume and training time.
- Four accent themes and two extra share-card styles.
Locked features don't disappear. Each one shows a small gold card saying what it would do, and the stats screen renders your real numbers blurred behind an "Unlock" button. Seeing your own data is a much better pitch than a feature list.
Play Billing: three rules
Billing Library 8 is pleasant to use, but three details matter:
- Acknowledge non-consumables. If Pro for life isn't acknowledged within three days, Google refunds it automatically.
- Consume tips. A tip that isn't consumed can't be bought again ("You already own this item").
-
Play is the source of truth. Pro for life is restored from
queryPurchasesAsyncon every connection, so it follows the Google Play account to new phones. A cached flag only covers offline launches.
when {
ProCatalog.PRO_LIFETIME in purchase.products && !purchase.isAcknowledged ->
client.acknowledgePurchase(AcknowledgePurchaseParams.newBuilder()
.setPurchaseToken(purchase.purchaseToken).build()) { /* ProUnlocked */ }
SupportTip.forProduct(purchase.products.first()) != null ->
client.consumeAsync(ConsumeParams.newBuilder()
.setPurchaseToken(purchase.purchaseToken).build()) { _, _ -> /* TipReceived */ }
}
Purchase events go through a buffered Channel, collected at the app root rather than on the Pro page. A payment can finish while you're somewhere else in the app, and the thank-you still has to appear.
The first version of ad hours trusted the phone
My first implementation of "one ad, one hour" did the obvious thing: when AdMob reported a reward, the app wrote a new proUntil timestamp to the user's Firestore document.
It worked, and it was trivially abusable. Anyone could write proUntil: 2099 to their own document, change the phone's clock to reset a "5 ads per day" limit, or replay the write.
So the rule became: the app never writes Pro time. A server does, and only after Google confirms the ad was watched.
AdMob server-side verification
AdMob supports exactly this. You give the ad unit a callback URL. When someone finishes a rewarded ad, Google calls that URL with the reward details and an ECDSA signature made with keys it publishes.
The app sets the Firebase user ID on the ad before showing it:
ad.setServerSideVerificationOptions(
ServerSideVerificationOptions.Builder().setUserId(uid).build()
)
The callback is a Firebase Cloud Function. It verifies the signature against Google's published keys, then grants the hour inside a Firestore transaction using the server's clock:
function grantAdHour(state, now, transactionId) {
if (state.transactions.includes(transactionId)) return { granted: false, reason: "duplicate" };
const recent = state.adTimes.filter((t) => now - t < DAY);
if (recent.length >= 5) return { granted: false, reason: "daily_limit" };
if (Math.max(0, state.untilMillis - now) + HOUR > 8 * HOUR) return { granted: false, reason: "bank_full" };
return {
granted: true,
untilMillis: Math.max(now, state.untilMillis) + HOUR,
adTimes: [...recent, now],
transactions: [...state.transactions, transactionId].slice(-20),
};
}
Three details in there came from thinking about how it could go wrong:
- A rolling 24 hours instead of "per day". A calendar day depends on a time zone, and the phone's time zone is under the user's control.
- Transaction IDs are remembered. AdMob retries callbacks, and a retry must not grant a second hour.
- The function answers 200 even when a limit is hit. The callback was genuine, so retrying won't change anything.
The logic is a plain function with no Firebase imports, so it has unit tests. The signature check has tests too, using a key pair generated in the test itself.
Locking the fields with Firestore rules
The server can only be the sole writer if the client is stopped from writing. Firestore rules can compare an update with the stored document:
function serverOwned() { return ['proUntil', 'proAdTimes', 'proAdTxns']; }
match /users/{uid} {
allow update: if isOwner(uid)
&& !request.resource.data.diff(resource.data).affectedKeys().hasAny(serverOwned());
match /{collection}/{document=**} {
allow read, write: if isOwner(uid);
}
}
That inner match first read match /{document=**}, and it would have quietly undone everything. A recursive wildcard matches zero or more segments, so it also matched the profile document itself and granted full write access to it. Putting {collection} first forces at least one segment.
I only trusted the rules after running them in the Firestore emulator: 11 tests covering normal profile edits, attempts to grant yourself Pro time, set-merge tricks, new accounts and other users. One test failed, and the bug was in the test, not the rules. Writing [] over an empty array changes nothing, so it was allowed. Seeding a real value fixed it.
The 403 that taught me how Google signs
The first time AdMob's "Verify URL" button called the function, it returned 403. The signature was being rejected.
I was verifying the raw query string exactly as received. Google's own verifier, in Tink's RewardedAdsVerifier, reads the query with Java's URI.getQuery(), which percent-decodes it before checking. Matching that was a one-line change:
const message = decodeURIComponent(rawQuery.slice(0, rawQuery.indexOf("&signature=")));
I also made a failed download of Google's keys return 503 instead of 403, so AdMob retries later instead of treating it as forged. After a redeploy, AdMob showed "Your callback URL has been verified".
Testing real ads without risking the AdMob account
Google's shared test ad unit never calls your server, so it can't test this flow. Clicking real ads on your own phone can get an AdMob account suspended.
The answer is a registered test device: the real ad unit serves labelled test ads, and the callback still fires. The device ID AdMob expects is the MD5 of the app's ANDROID_ID, so debug builds register whatever device they run on:
if (BuildConfig.DEBUG) {
val id = MessageDigest.getInstance("MD5")
.digest(androidId.toByteArray()).joinToString("") { "%02X".format(it) }
MobileAds.setRequestConfiguration(
RequestConfiguration.Builder().setTestDeviceIds(listOf(id)).build())
}
On the first try, Logcat said "This request is sent from a test device", and the function logged granted: true for my account.
Two things the Today page got wrong
While building Pro I kept finding smaller problems.
-
Every set was number 1. The loader for the Today page hard-coded
setNumber = 1. Sets are now numbered in the order they were logged, per exercise and per side, and warm-ups show "W". - Training time didn't exist. Workouts started from workout mode already stored their duration, but sets logged from the exercise list had nothing. Today now groups any sets logged outside a workout into sessions, splitting at gaps longer than 45 minutes so morning and evening training stay apart, and merges overlaps so nothing is counted twice. The stats screen uses the same function to show time per week.
The paperwork
Selling things on Google Play brought its own list of steps, most of them outside the code:
- A merchant account. I reused my existing individual payments profile, the one AdMob already pays into. You don't need a company to sell as an individual.
- The 15% service fee. It isn't automatic: you create an account group and accept the terms. Otherwise Google takes 30%.
-
Products need an uploaded build. The one-time products page stays locked until a bundle with the
BILLINGpermission is in a track. I uploaded 1.6.0 to Internal testing first. - License testers. I created a list with just my own email. The existing tester list wasn't used, because license testers buy for free.
- Data safety. Purchase history is now declared as collected, optional and used for app functionality.
- Terms and privacy in five languages. Both gained a section on Pro, purchases and server-verified ad hours. The website changes were pushed together with the release, not earlier, so the published policy never described an app that wasn't on the store.
Then I tested everything from the Internal testing track with Play's test card: Pro for life, all three tips, and the same tip twice to prove it was consumed. The receipts said "Test:", the prices showed in local currency, and the Supporter badge appeared.
What I'd tell myself before adding payments
- Decide what stays free before writing any code. It shapes every screen.
- If a reward has value, the client must not be able to grant it. Put the grant behind a server and lock the fields with rules.
- Test security rules in the emulator, including the attempts that should fail.
- When a signature doesn't verify, read the reference verifier before assuming the keys are wrong.
- Buy everything once on a test track, including the same consumable twice, before sending a release to review.
Version 1.6.0 is in Play review as I write this. Free training stays free, and nobody sees an ad unless they ask for one.
How do you monetize a small app you'd still want to use yourself: one-time purchase, subscription, optional ads or tips?
Google Play: DotShredzilla
Source: github.com/kareem2099/Shredzilla
Privacy & terms: dotsuite.dev
Support: support@dotsuite.dev



Top comments (2)
This is a really thoughtful monetization design — especially the rule that everything you need to train stays free and Pro is only the layer that interprets your data. That's the kind of line most indie apps never draw clearly, and it shows in the locked-feature gold cards too.
The server-side verification part stood out to me. The rolling 24-hour window instead of a calendar day is a smart call, and the Firestore wildcard bug (match /{document=**} quietly matching the profile doc itself) is exactly the kind of thing that would have shipped silently without the emulator tests. Curious about one detail: the screenshot shows 3h banked of 8 — is that 8-hour bank cap enforced on the server as well, or just in the UI? And have you seen many users actually use the ad-hours path versus going straight for Pro for life?
Thanks, that's exactly the line I wanted to draw.
Yes, the 8-hour cap is enforced on the server, in the same transaction as the other checks.
grantAdHourrefuses the hour if the time left plus one hour would go over 8, and the newproUntilis also capped at now + 8 hours. The app only displays what the server wrote: the Firestore rules don't let it writeproUntilat all.(Small note: the "3 h banked of 8" card on the cover is an illustration, not a real account.)
On usage, honestly: nobody yet. Pro and ad hours shipped two weeks ago, and the only rewarded ad in my AdMob dashboard is the one I watched while testing. That's expected for a new app, so right now I care more about people sticking with it than about revenue. I'll share real numbers once there are some.