A More Secure Android Referral System
A three-page guide on why simple referral codes are easy to abuse, which Google Play tools make them safer, and what to fix before you launch.
Get the PDF
Free. No email or account needed. PDF · 187 KB
The preview only loads when you tap "Read PDF here", which saves mobile data. Download gives you the original PDF file.
Key takeaways
- A valid referral code does not prove a genuine new user was acquired.
- Install Referrer, Play Integrity and Device Recall each answer a different question.
- Define success as attribution + identity + onboarding + integrity + server validation.
- Rewards belong to the server, never to a client flag.
- A temporary outage is not fraud — keep the referral pending and retry.
This is the short version of how I built the referral system for my app ReelBlink. It covers why simple referral-code systems are easy to abuse, which Google Play tools make them stronger, and what to test before you ship.
The mistake most referral systems make
The usual flow is: generate a code, a friend enters it, the code is valid, give the reward. It is easy to build, but a valid referral code does not prove you gained a genuine new user.
People can refer themselves, create several accounts, uninstall and reinstall, switch Google accounts, replay the same request, or modify the app.
A referral code should answer only one question: who gets the credit? It should never be the proof that the referral is genuine.
What each tool answers
| Tool | The question it answers |
|---|---|
| Play Install Referrer | Where did this installation come from? |
| Authentication | Which user or account is this? |
| Play Integrity API | Does this request come from the expected Play app on a normal device? |
| Server validation | Does this referral meet our rules? |
| Device Recall | Has this device already taken part in this one-time promotion? |
Google Play has no ready-made referral program. You still build the reward logic, the referral UI, the rules, the backend checks and the reward storage yourself. These tools are only the building blocks.
Define a "successful referral" properly
A link click is not a successful referral, and neither is an install on its own. A successful referral needs all of these together:
Referral attribution + an eligible new user + authentication + the required onboarding + an integrity check + server validation
When you detect attribution, mark the referral as pending. The app may ask for a reward, but the server decides whether it is valid.
Abuse cases and how to stop them
| Abuse case | Protection |
|---|---|
| Self-referral | The referrer must be a different user from the referred user |
| Same account after reinstall | Account history kept on the server |
| The same referred user reused | A one-time qualification rule |
| An existing user posing as new | Account creation time, install info, eligible app version |
| A fake or modified app | Play Integrity |
| Replaying the same request | Idempotency, unique request IDs, database constraints |
| Claiming one reward twice | An atomic claim on the server |
| Same phone, new account | Device Recall, where available |
| Link clicked, no conversion | No reward |
| Installed, but never qualifies | No reward |
Rules that keep it honest
- Rewards belong to the server. Never let the app set something like
premiumPackUnlocked = true. The server checks eligibility and grants the reward. - Never trust a claim from the app. Sending
integrityPassed = truefrom the app proves nothing. Verify the integrity token on the server. - Keep a reward history, not just a counter. It gives you an audit trail, duplicate protection and answers for support questions.
- Use a stable internal user ID as the main identifier. It works better than an email address.
- A temporary failure is not fraud. During an outage or a rate limit, keep the referral pending and retry. Do not burn a genuine user's reward.
Device Recall: useful, but not required for v1
Play Integrity does not solve the "same phone, new account" case on its own. Device Recall can, because it remembers a small amount of abuse-related state for a device. When I wrote the original guide, it was available through a beta, controlled-access process. The interest form asked for the developer account, the app package, the linked Cloud project and the abuse problem you want to solve.
A strong first version works without it: install referrer + authentication + Play Integrity + server validation. If Device Recall is not enabled, do not claim that same-device abuse is solved.
Linking a Google Cloud project for Play Integrity does not mean your backend has to run on Google Cloud Run. The project is only for API setup and authorization.
Common mistakes
- Rewarding a link click, or an install with no further checks
- Treating a manual referral code as complete proof
- Trusting a user identity or
referralSuccessful = truesent by the app - Storing permanent rewards only on the phone
- Letting the app grant itself paid access
- Skipping idempotency or duplicate checks on the server
- Treating an infrastructure failure as user fraud
- Claiming Device Recall protection before it is enabled
- Tying referral rewards to Play Store ratings or reviews
Test before you ship
- A genuine referral succeeds.
- Self-referral fails.
- The same account cannot qualify twice.
- An existing user cannot become a fake "new user".
- Invalid attribution is rejected.
- A replayed request creates no second reward.
- One reward cannot unlock two items.
- An invalid reward choice does not use up the reward.
- A modified or unrecognised app cannot claim a reward.
- A temporary server failure does not permanently burn a referral.
- The reward survives a reinstall and an account restore.
- Switching accounts does not leak rewards.
- Same-device, new-account abuse is blocked, if Device Recall is enabled.
The main lesson
Generating a referral link is the easy part. The hard part is proving three things: a genuinely new user was brought by the right referrer, the app and the request are legitimate, and the reward has not already been earned or claimed.
Attribution + identity + integrity + server validation + anti-abuse rules
This guide is condensed from "How I Built a More Secure Referral System for ReelBlink".