On this page
Fraudsters automate sign-ups, farm promotions, scrape APIs and abuse paid features using modified apps or emulators. Client-side checks are easy to bypass. The Play Integrity API moves the decision to your server, using signed verdicts from Google Play.
How it works
The verdicts
| Verdict | Question it answers | Example values |
|---|---|---|
| Request details | Is this token for this request? | Package name, request hash, timestamp |
| App integrity | Is this your unmodified app, as distributed by Play? | PLAY_RECOGNIZED, UNRECOGNIZED_VERSION |
| Device integrity | Is it a genuine, certified Android device? | MEETS_DEVICE_INTEGRITY, MEETS_BASIC_INTEGRITY, MEETS_STRONG_INTEGRITY |
| Account details | Did the user get the app from Play (licensed)? | LICENSED, UNLICENSED |
| Optional signals | Additional environment details | See current docs (for example app access risk) |
Client code (standard request)
class IntegrityClient(context: Context, private val cloudProjectNumber: Long) {
private val manager = IntegrityManagerFactory.createStandard(context)
private var provider: StandardIntegrityManager.StandardIntegrityTokenProvider? = null
/** Call early (e.g. app start); preparation can take a few seconds. */
suspend fun warmUp() {
provider = manager.prepareIntegrityToken(
StandardIntegrityManager.PrepareIntegrityTokenRequest.builder()
.setCloudProjectNumber(cloudProjectNumber)
.build()
).await()
}
/** requestHash binds the token to THIS action (e.g. SHA-256 of "redeem:$couponCode:$userId"). */
suspend fun token(requestHash: String): String {
val p = provider ?: run { warmUp(); provider!! }
return p.request(
StandardIntegrityManager.StandardIntegrityTokenRequest.builder()
.setRequestHash(requestHash)
.build()
).await().token()
}
}Server-side verification
- Receive the token with the action payload.
- Call Google's
decodeIntegrityTokenAPI using service-account credentials (server only). - Check that package name and request hash match this exact action, and that the timestamp is recent.
- Evaluate the app, device and account verdicts against your risk policy.
- Decide: allow, require step-up (OTP, CAPTCHA, review), rate-limit, or deny.
Designing a fair response policy
- Tier by risk: require integrity for redeeming money or high-value promotions, not for reading articles.
- Don't hard-block too eagerly: some legitimate users have older or uncertified devices. Prefer step-up or limited functionality.
- Handle API errors gracefully: network issues or outdated Play services shouldn't lock users out. Retry or fall back to other checks.
- Monitor verdict distributions to tune your thresholds.
With Firebase
If your backend is Firebase (Firestore, Functions, AI Logic), App Check with the Play Integrity provider applies integrity checks to Firebase requests for you. See Gemini API Integration for an example.
Use cases
Promotion abuse
Require good device and app integrity for referral rewards, and step up for borderline verdicts.
API scraping
Integrity tokens on sensitive endpoints, plus rate limits per account.
Paid features
Check app integrity and licensing for premium content unlocks.
Common mistakes
- Decoding or evaluating the verdict on the device.
- Not binding tokens to the request (missing request hash), which enables replay.
- Calling the API on every request. Use it for sensitive actions, within quota.
- Blocking all users on API errors.
Frequently asked questions
Is Play Integrity the replacement for SafetyNet Attestation?
Yes. SafetyNet Attestation was deprecated in favour of the Play Integrity API.
Does it work for apps not installed from Play?
Verdicts will reflect that, for example as unrecognized or unlicensed. Decide how your policy treats sideloaded installs.
Are there usage limits?
Yes, there are daily quotas, which can be increased on request. Check the current documentation and design calls around sensitive actions.
Conclusion
Play Integrity gives your server trustworthy signals about the app, device and account behind a request. Bind tokens to actions with request hashes, verify server-side, apply a graduated risk policy, and handle errors without punishing legitimate users.
Next step: review the threats it helps with in Common Android Security Vulnerabilities.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
Walzi4K wallpapers for lock and home screenGet it โธ
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Ready to build real Android applications?
Security is easiest to get right when it is part of how you build from the first screen. Strengthen the Android fundamentals that secure, privacy-respecting apps are built on.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.