Get started
1Introduction
Scrollock helps people stop doomscrolling. On Android a native Kotlin engine blocks chosen apps on a schedule, during focus sessions and after daily limits – even when the Flutter UI is closed. The same codebase runs on iOS as a planner, focus timer and insights app (iOS blocking needs Apple's Screen Time entitlement and is not included).




Features
- Blocking engine (Android): schedules (overnight, weekdays, strict), focus sessions (Deep Focus, Pomodoro, Study, Work, Sleep, Custom), "everything except" allow-list sessions, daily time limits, combined social limit, opens-per-day limits, mindful-open pause, emergency breaks, Do Not Disturb, silencing notifications of blocked apps, protected system apps, boot recovery, watchdog, home-screen widget, Quick Settings tile, launcher shortcut.
- Experience: guided onboarding and tour, insights (screen time, weekly focus, heatmap, streaks, focus score), focus garden, breathing exercise, wake/bed rhythm with local reminders, PIN lock, light/dark mode, 6 color themes, English/Spanish/Bengali.
- Business: Scrollock Plus with plans you configure (shipped as monthly, yearly with free trial and lifetime; prices are set in the stores, see section 8), tip jar, invite-friends referrals, AdMob banner/interstitial/rewarded with GDPR consent, push campaigns, Remote Config switches, opt-in analytics, in-app review prompt, share/rate.
- Firebase (optional): Google / Apple / guest sign-in with account linking, cloud backup and restore, accountability partner, Crashlytics (opt-in), server-side purchase verification, account deletion.
2Requirements
| Tool | Version |
|---|---|
| Flutter | 3.47.0 or newer (tested with 3.47.7) |
| Dart | 3.13.5 or newer (comes with Flutter) |
| Android Studio + Android SDK | compileSdk / targetSdk 36, minSdk 24 (Android 7.0) |
| JDK | 17 |
| Xcode (iOS only) | 16 or newer, iOS 15.0+ deployment target, a Mac |
| Node.js (Cloud Functions only) | 22 |
| Firebase CLI (optional) | latest: npm install -g firebase-tools |
Accounts you may need (you pay their fees): Google Play Console, Apple Developer Program, Firebase (Spark free plan; Blaze for Cloud Functions), AdMob.
Good to know before you start
- Blocking is Android only. On iOS the app is a focus timer, planner and insights app. Blocking other apps on iOS needs Apple's Family Controls (Screen Time) entitlement, which Apple grants per app and which is not included.
- No app can make blocking impossible to bypass. Force-stop, uninstall and aggressive battery managers can interrupt any blocker. Scrollock restarts protection where Android allows it and shows the user when protection stops.
- No accounts, keys or credits are included. See Costs and responsibilities.
3Quick start: run the app
- Unzip
Files/and open the folder in Android Studio or VS Code. - Get packages and run on a phone or emulator:
flutter pub get flutter run - Without Firebase files the app starts in local-only mode: blocking, sessions, insights and ads work; the Account page explains how to enable cloud backup.
- On first start the app guides you through Usage access and Display over other apps. On an emulator you can grant them with adb:
adb shell appops set com.vertexstation.scrollock GET_USAGE_STATS allow adb shell appops set com.vertexstation.scrollock SYSTEM_ALERT_WINDOW allow - iOS: open
ios/Runner.xcworkspacein Xcode once, choose your Team in Signing & Capabilities, thenflutter run.
4Folder structure
Files/
lib/
core/ app_config.dart (edit me), theme, widgets, translations (i18n_*.dart)
data/ local store, native bridge, Firebase (cloud_sync, push_service,
remote_flags, analytics)
domain/ models/ (rules, sessions, settings, focus_state), rules engine
(pure Dart), FocusCubit
monetization/ plus_cubit (billing), paywall, tip jar, ads_service, plus_gate,
post_session (offer, review, interstitial), referral_service,
invite_screen
features/ onboarding, shell (tabs, tour), home, schedule, apps, insights,
session (start sheet, timer, breathing), settings (account,
sign-in, rhythm, PIN), permissions, garden
android/app/src/main/kotlin/com/vertexstation/scrollock/
native engine: EngineService, Rules, UsageTracker, BlockActivity,
BlockOverlay, NotificationBlocker, Nudges, Push, FocusWidget,
FocusTileService, Watchdog, BootReceiver, OemSettings ...
ios/ Runner (Info.plist, entitlements, PrivacyInfo.xcprivacy)
functions/ Cloud Functions: verifyPurchase, playNotifications,
appleNotifications, cleanupUser, getReferralCode, redeemReferral
test/ unit tests (rules engine, cubit, purchases, ad pacing, i18n)
firestore.rules firestore.indexes.json firebase.json remoteconfig.template.json
The code is organised by feature. Where to find each kind of file:
| Kind | Where |
|---|---|
| Models | lib/domain/models/ (rules, sessions, settings, focus state) |
| Blocs / state management (Cubit) | lib/domain/focus_cubit.dart, lib/monetization/plus_cubit.dart |
| Services (data, Firebase, native bridge) | lib/data/ |
| Screens / pages | lib/features/<feature>/*_screen.dart and lib/monetization/*_screen.dart |
| Shared widgets | lib/core/widgets.dart (cards, buttons, rings, setting rows) |
| Utils, theme, config, translations | lib/core/ (app_config.dart, theme.dart, i18n*.dart) |
| Routes and app start | lib/app.dart (go_router routes, theme), lib/main.dart (service setup) |
Long lists and grids (apps, schedules, garden, app picker) are built lazily with SliverList.builder, SliverGrid.builder and ListView.builder.
5How it works
Architecture
- Flutter UI and state – screens in
lib/featuresread and change oneFocusCubit(lib/domain/focus_cubit.dart). Everything the user sets up (apps, schedules, limits, sessions, history, settings) is oneFocusStatesaved as JSON inshared_preferencesbyLocalStore, with a backup copy. - Bridge – after every change the cubit sends the rules to Android over the
scrollock/engineMethodChannel (lib/data/engine_bridge.dart, methodsync). The same channel returns protection health, usage stats and blocked attempts. - Native engine (Android) –
EngineServiceis a foreground service that keeps running when the app is closed. It polls the foreground app with Usage Access (UsageTracker), checks the rules (Rules.kt, the Kotlin twin oflib/domain/rules_engine.dart) and showsBlockActivityover a blocked app. If a phone blocks that,BlockOverlayis used as a fallback.BootReceiverandWatchdogrestart protection. - Firebase (optional) –
lib/data/cloud_sync.darthandles sign-in, backup/restore and partner sharing; Cloud Functions verify purchases and referrals. Without Firebase files the app runs in local-only mode.
Blocking decisions are made on the phone. App usage never leaves the device; only the daily totals and settings are included in an optional cloud backup.
Permissions
| Permission / access | Why | Needed? |
|---|---|---|
Usage access (PACKAGE_USAGE_STATS) | Know which app is open, measure screen time and limits | Required for blocking |
Display over other apps (SYSTEM_ALERT_WINDOW) | Show the block screen over a blocked app | Required for blocking |
Foreground service (specialUse) | Keep the engine running while the app is closed | Required for blocking |
Notifications (POST_NOTIFICATIONS) | Time warnings, reminders, push messages, the service notification | Recommended |
| Ignore battery optimization | Stop the phone from killing the engine | Recommended |
Start at boot (RECEIVE_BOOT_COMPLETED) | Restart protection after a restart | Automatic |
| Notification access (listener service) | Silence notifications of blocked apps | Optional (setting) |
Do Not Disturb access (ACCESS_NOTIFICATION_POLICY) | "Do Not Disturb while focusing" | Optional (setting) |
| Internet | Firebase, ads, purchases | Automatic |
The app does not use the Accessibility Service or QUERY_ALL_PACKAGES; launchable apps are listed through a <queries> intent filter.
Screens and where to change them








| Screen | File | What it does |
|---|---|---|
| Onboarding, guided tour | features/onboarding/onboarding_screen.dart, features/shell/tour_overlay.dart | Intro, daily goal, pick apps, optional sign-in step, then "Grant access" opens the permissions guide; tour of the tabs |
| Home | features/home/home_screen.dart | Protection status, current session or schedule, blocked apps, quick start, today's numbers, time left |
| Start sheet, session, breathing | features/session/ | Mode, duration or "until", allow-list or block list, strict mode; timer with +15 min, breathe and emergency breaks |
| Schedules | features/schedule/ | Recurring rules with days, overnight ranges and strict schedules; free limit in AppConfig.freeMaxSchedules |
| Apps | features/apps/ | Block list, daily time and opens limits, combined social limit, mindful apps |
| Insights | features/insights/ | Screen time, weekly chart, streaks, focus score; Plus heatmap and CSV export in plus_history.dart |
| Garden | features/garden/garden_screen.dart | A plant per finished session; rare plants for Plus |
| Permissions, protection check | features/permissions/ | Grant access, run a live block test, battery shortcuts per phone brand |
| Settings, rhythm, PIN, account | features/settings/ | Strict mode, breaks, warnings, DND, themes, language, privacy, backup, partner, sign-in, deletion |
| Paywall, tips, invite | monetization/ | Plus plans from the store, tip jar, invite friends |
| Native block screen | android/.../BlockScreen.kt, BlockActivity.kt | The screen shown over a blocked app; its texts come from blockStrings in engine_bridge.dart |
6The config file
Almost everything you change lives in lib/core/app_config.dart:
| Setting | What it does |
|---|---|
appName, supportEmail, websiteUrl | Brand texts and the "Contact support" address |
privacyPolicyUrl, termsUrl | Shown in Settings and on the paywall (required by Google Play and Apple for subscriptions) |
androidPackageId, iosAppStoreId | Used for "Rate the app", "Share" and the update dialog |
enablePurchases, enableTips, enableAds, enablePush, enableAppleSignIn | Master switches. Example: ads-only app → enablePurchases = false (every feature becomes free, ads stay) |
verifyPurchasesOnServer | Use the verifyPurchase Cloud Function when Firebase is configured |
plusPlans, tips | Your Plus plans and tip products (store ids, titles, plan type). Prices are never in the app – see Your plans, prices and free limits |
enableReferrals, referralDays, referralMaxPerYear | Invite friends: on/off, 7 days of Plus per side, at most 10 rewards a year per inviter. If you change the numbers, change the same constants in functions/index.js (a test checks they match) |
| Free-tier limits | 2 schedules, 3 limited apps, 2 mindful apps (also in Remote Config) |
| AdMob unit ids | Google's test ids for Android and iOS (replace before release) |
| Ad pacing | Interstitial every 3 completed sessions, 15 min apart (also in Remote Config) |
Make it yours
7Rename and re-brand
The product name, links and ids live in a few clearly marked places. You never need to search through the screens: every text in the app goes through the translation helper, which swaps the name for AppConfig.appName.
App name – change these 3 places
| File | Setting | Used for |
|---|---|---|
lib/core/app_config.dart | appName | Every text inside the app (all languages), share texts, reports |
android/app/src/main/res/values/strings.xml | app_name | Launcher name, notifications and the native block screen on Android |
ios/Runner/Info.plist | CFBundleDisplayName, CFBundleName, NSUserTrackingUsageDescription | Home-screen name and the iOS tracking message |
Optional: the Quick Settings tile label (tile_label) and the launcher shortcut texts in the same strings.xml.
Links, support and store ids
In lib/core/app_config.dart: supportEmail, websiteUrl, privacyPolicyUrl, termsUrl, androidPackageId and iosAppStoreId. They drive "Contact support", the legal links on the paywall and in Settings, "Rate the app", "Share" and the update dialog.
Package id / bundle id
- Android: change
applicationIdandnamespaceinandroid/app/build.gradle.kts. - Move
android/app/src/main/kotlin/com/vertexstation/scrollockto your path (for examplecom/yourcompany/yourapp) and update thepackageline at the top of each Kotlin file. - Search and replace
com.vertexstation.scrollockinAndroidManifest.xml,res/xml/shortcuts.xml,lib/core/app_config.dart(androidPackageId) andfunctions/env.example(ANDROID_PACKAGE_NAME). - iOS: Xcode → Runner target → General → Bundle Identifier.
- Create new Firebase apps for the new ids and download fresh
google-services.json/GoogleService-Info.plist.
Icon, colors, fonts
- Icon: replace
assets/icon/icon.png(1024×1024) andicon_foreground.png, then rundart run flutter_launcher_icons. Notification icon:res/drawable/ic_stat_shield.xml. - Colors:
lib/core/theme.dart→Pal.accents. Thetealentry is the default brand; each entry is[main, soft, gradient start, gradient end, light text]. Native block screen colors:BlockScreen.kt. - The app uses the platform's system font, so there are no font files or font licences to manage.
flutter test and flutter analyze, then open Settings → About and the paywall to see the new name and links.8Your plans, prices and free limits
The app never contains prices. You decide which plans you sell, what they cost, whether there is a free trial and what stays free. Prices are set in Google Play Console and App Store Connect and shown in each user's own currency, so you can change them at any time without an app update.
What to change, and where
| You want to… | Do this | App update? |
|---|---|---|
| Change a price | Edit the price in Play Console (subscription base plan / in-app product) and App Store Connect | No |
| Add or remove a free trial | Play Console: add a free-trial offer to the base plan. App Store Connect: add an introductory offer. The paywall shows "7 days free" automatically | No |
| Sell fewer plans (for example only lifetime) | Only create those products in the stores. Plans that the store does not return are hidden automatically | No |
| Change the preselected plan | Remote Config key paywall_default_plan (any plan id), or put that plan first in plusPlans | No (Remote Config) |
| Add, rename or reorder plans (for example a weekly or 6-month plan) | Edit AppConfig.plusPlans (below), create the products in both stores and add the ids to functions/index.js | Yes |
| Change free-tier limits | freeMaxSchedules, freeMaxLimitedApps, freeMaxMindfulApps in app_config.dart, or Remote Config free_max_schedules / free_max_limits / free_max_mindful | No (Remote Config) |
| Make every feature free (ads-only or free app) | enablePurchases = false | Yes |
| Hide the tip jar / change tips | enableTips = false, or edit AppConfig.tips and the matching store products | Yes |
| Rewarded "try Plus" length | rewardPlusHours or Remote Config reward_plus_hours | No (Remote Config) |
| Invite-friends reward | referralDays / referralMaxPerYear in app_config.dart and the same constants in functions/index.js | Yes |
Editing the plan list
Plans are listed in lib/core/app_config.dart, in the order the paywall shows them:
static const plusPlans = [
PlusPlan(id: 'plus_yearly', title: 'Yearly', period: 'per year', kind: PlanKind.subscription, months: 12),
PlusPlan(id: 'plus_monthly', title: 'Monthly', period: 'per month', kind: PlanKind.subscription, months: 1),
PlusPlan(id: 'plus_lifetime', title: 'Lifetime', period: 'once', kind: PlanKind.lifetime),
// Example: a weekly plan
// PlusPlan(id: 'plus_weekly', title: 'Weekly', period: 'per week', kind: PlanKind.subscription, months: 0),
];
- id – the product id. Create a product with exactly this id in Play Console and App Store Connect (subscription for
PlanKind.subscription, one-time / non-consumable forPlanKind.lifetime). - title and period – English texts shown on the plan card. They are translated like every other text; if you use new words (for example "Weekly"), add them to
lib/core/i18n_es.dartandi18n_bn.dart. - months – billing period of a subscription. It is used for the "Save x%" badge (compared with the shortest subscription you sell) and to estimate the end date when no server check is available. Use 0 for lifetime and for periods shorter than a month (the end date is then estimated as 8 days until the store confirms the renewal).
- Add every plan id to
SUBSCRIPTIONSorLIFETIMEat the top offunctions/index.js, then deploy the functions.flutter testfails if you forget.
PlusCubit.loadProducts). On a device without Google Play (or before your products are approved) it shows "The store is not available on this device" instead of a price – that is expected.Which features are Plus-only
Each locked feature calls requirePlus(context, reason) from lib/monetization/plus_gate.dart. Remove a call to make that feature free; add one to lock something else. The paywall feature list is _features in lib/monetization/paywall_screen.dart.
| Feature | File |
|---|---|
| More schedules than the free limit | features/schedule/schedule_screen.dart |
| Strict mode | features/settings/settings_screen.dart, features/session/start_sheet.dart, features/schedule/schedule_editor_screen.dart |
| More app limits / mindful apps than the free limit | features/apps/apps_screen.dart |
| History heatmap and CSV export | features/insights/plus_history.dart |
| Automatic backup, accountability partner | features/settings/account_screen.dart |
| Color themes | features/settings/settings_extras.dart |
| Rare garden plants | features/garden/garden_screen.dart |
9Languages and texts
English text is the key. Spanish and Bengali live in lib/core/i18n_es.dart and i18n_bn.dart. To add a language: copy one of these files, translate the values, register it in lib/core/i18n.dart (supported and t()), and add its blockStrings case in lib/data/engine_bridge.dart for the native block screen. flutter test fails if a visible string is missing.
Backend and services
10Firebase setup (optional)
- Create a project at console.firebase.google.com. Analytics can stay on.
- Authentication → Sign-in method: enable Google, Anonymous and (for iOS) Apple. Set a support email.
- Project settings → Your apps → Add app → Android with your package id. Add your SHA-1 and SHA-256 fingerprints (debug:
cd android && ./gradlew signingReport; release: from Play Console → App integrity). Downloadgoogle-services.jsonintoandroid/app/. Download it after enabling Google sign-in so it contains the web client id. - Add app → iOS with your bundle id. Download
GoogleService-Info.plist, drag it intoRunnerin Xcode (Copy items if needed). Copy itsREVERSED_CLIENT_IDintoios/Runner/Info.plist, replacingcom.googleusercontent.apps.REPLACE-WITH-YOUR-REVERSED-CLIENT-ID. - Firestore Database → Create database (production mode, pick a location close to your users).
- Deploy rules and indexes:
npm install -g firebase-tools firebase login firebase use --add # choose your project firebase deploy --only firestore
Quick test: is Firebase connected?
- Run the app with your real
google-services.jsonand open Settings → Cloud backup → Continue as guest. A profile card ("Guest") appears: Authentication works. - Tap Back up now and wait for "Backup complete". In the Firebase console, Firestore → users now has a document with your user id: Firestore and the rules work.
- Tap Sign in with Google (or "Link Google account"). The card shows your name and photo: Google sign-in and the SHA keys are correct.
- Push: in the console open Messaging → New campaign, send to topic
all. The notification arrives (app in background). - Remote Config: publish
ads_enabled = false, restart the app twice; banners disappear.
If step 1 shows "Sign-in failed", Anonymous sign-in is not enabled; if step 2 shows "permission-denied", the rules were not deployed (see Troubleshooting).
Tip: copying google-services.json.example to google-services.json lets the project build with the Firebase plugins (useful to check your setup), but every Firebase call fails until you use the real file – the app then shows calm error messages and keeps working offline.
The Google Services and Crashlytics Gradle plugins are applied automatically when google-services.json exists (see android/app/build.gradle.kts). The *.example files show the expected format; never commit the real files to a public repository.
users/{uid} (settings, selected apps), sub-collections schedules, appRules, dailySummaries, sessions, devices, entitlements (server-written); partners/{code}; purchases/{id} (server only). The app usage timeline is never uploaded.11Sign-in (Google, Apple, guest)
- Sign-in is optional. Users see it as the last onboarding step ("Back up your progress", can be skipped) and on the Account page.
- Guest → Google/Apple upgrade: a guest account is linked in place, so the uid, cloud backup and purchases stay. If the Google account already exists, the app switches to it (local data on the phone is untouched).
- Google on Android: works with the web client id from
google-services.json. You can override it with--dart-define=GOOGLE_SERVER_CLIENT_ID=xxx.apps.googleusercontent.com. - Sign in with Apple (iOS) is required by App Store guideline 4.8 when Google sign-in is offered:
- Apple Developer → Identifiers → your App ID → enable Sign In with Apple.
- The entitlement is already in
ios/Runner/Runner.entitlements. In Xcode → Signing & Capabilities you should see "Sign in with Apple". - Enable the Apple provider in Firebase Authentication.
- Account deletion (Account → Delete account) removes cloud data and the Firebase account, re-authenticates when Firebase asks for it and revokes the Apple token. The
cleanupUserfunction removes server-written purchase records.
12Store products (Google Play and App Store)
Billing uses the official in_app_purchase plugin (Google Play Billing and StoreKit 2). This section is the store side; which plans exist and what they cost is your decision – see Your plans, prices and free limits.
What Plus unlocks
| Feature | Free | Plus |
|---|---|---|
| Focus sessions, block screen, widget, tile, reminders, insights (7 days) | ✔ | ✔ |
| Schedules | 2 | unlimited |
| Apps with time / open limits | 3 | unlimited |
| Mindful-open apps | 2 | unlimited |
| Strict mode (sessions and schedules) | – | ✔ |
| History heatmap, CSV export | – | ✔ |
| Automatic backup, accountability partner | manual backup | ✔ |
| Color themes, rare garden plants | – | ✔ |
| Ads | yes | none |
Gates live in lib/monetization/plus_gate.dart (requirePlus(context, reason)) and are called from the screens. When Plus ends, strict mode switches off (never during an active strict window); rules the user created stay.
Google Play Console
- Upload a signed build to the internal testing track (billing only works for apps uploaded to Play).
- Monetize → Products → Subscriptions: create one subscription for every subscription plan in
AppConfig.plusPlans(shipped ids:plus_monthly,plus_yearly), each with an auto-renewing base plan and your own price. Optional: add a free-trial offer (for example 7 days on yearly); the paywall shows "7 days free" automatically. - Monetize → Products → In-app products: create your lifetime plan (shipped id
plus_lifetime) and the tip products fromAppConfig.tips(tip_small,tip_medium,tip_large). Tips are consumed automatically after purchase, so they can be bought again. - Setup → License testing: add your Google account so test purchases are free.
App Store Connect
- Create a subscription group "Plus" with your subscription plans (shipped:
plus_monthly,plus_yearly) and set your prices. Add an introductory free trial if you like. - Create the lifetime plan as Non-Consumable and the tips as Consumable.
- Fill in the Paid Apps agreement, tax and banking. Test with a Sandbox tester.
Restore and offline
"Restore purchases" is on the paywall. On start the app re-checks the store (Google Play owned purchases / StoreKit 2 current entitlements, no password prompt) and caches the result so Plus works offline. The rewarded ad ("Watch a short ad to try Plus for a day") unlocks Plus for reward_plus_hours.
When the paywall appears
From the Plus card in Settings, from a locked feature (with the reason) and once after the first completed session. Never during onboarding or a focus session.
13Cloud Functions (purchase checks)
Optional but recommended: the functions/ folder verifies every purchase with Google and Apple and writes users/{uid}/entitlements/plus, which clients can read but never write. Requires the Blaze plan (the free quota covers small apps).
| Function | Trigger | Job |
|---|---|---|
verifyPurchase | callable | Checks a purchase token (Play Developer API) or StoreKit 2 signed transaction (Apple library) and grants Plus |
playNotifications | Pub/Sub topic play-billing | Renewals, cancellations, refunds from Google Play RTDN |
appleNotifications | HTTPS | App Store Server Notifications V2 (renewals, refunds, revocations) |
cleanupUser | Auth delete | Removes entitlements, invite codes and detaches purchases when an account is deleted |
getReferralCode / redeemReferral | callable | Invite codes and the "both get a week of Plus" reward (section 9b) |
Deploy
cd functions
cp env.example .env # set ANDROID_PACKAGE_NAME, IOS_BUNDLE_ID, IOS_APP_APPLE_ID
npm ci
cd ..
firebase deploy --only functions,firestore
Google Play access
- Google Cloud console (same project) → enable the Google Play Android Developer API.
- Play Console → Users and permissions → Invite new user: the Functions service account (
PROJECT_ID@appspot.gserviceaccount.comor the compute default account shown in Cloud Functions details) with View financial data and Manage orders and subscriptions. It can take up to 24 h to take effect. - Real-time notifications: Google Cloud → Pub/Sub → create topic
play-billing, grantgoogle-play-developer-notifications@system.gserviceaccount.comthe Pub/Sub Publisher role, then Play Console → Monetize → Monetization setup → paste the full topic name and send a test notification.
App Store notifications
After deploying, copy the appleNotifications URL (Firebase console → Functions) into App Store Connect → App Information → App Store Server Notifications (Version 2) for production and sandbox.
14Invite friends (referrals)
"Give a week, get a week": every user gets a 6-character invite code (Settings → Invite friends, or from the paywall). When a new account redeems it, both people get 7 days of Plus. It brings free installs and lets more people experience Plus, which is when they are most likely to subscribe.
- Codes and rewards are created only by the
getReferralCodeandredeemReferralCloud Functions (Blaze plan) and stored inreferrals,referralCodesandusers/{uid}/entitlements/referral. Clients cannot write them. - Abuse limits: an account can redeem one code, only within 14 days of creating it, never its own; an inviter earns at most 10 weeks per 365 days. Change
REFERRAL_DAYS,REFERRAL_MAX_PER_YEARandREFERRAL_NEW_ACCOUNT_DAYSinfunctions/index.jsand the matching values inapp_config.dart(a unit test checks they match). - Rewards are free in-app content (no money or gift cards), which both Google Play and the App Store allow. Turn the feature off with
enableReferrals = false; it is hidden automatically when Firebase is not configured.
15AdMob ads and consent
| Where | What to replace |
|---|---|
android/app/src/main/AndroidManifest.xml | com.google.android.gms.ads.APPLICATION_ID (Android app id ca-app-pub-…~…) |
ios/Runner/Info.plist | GADApplicationIdentifier (iOS app id) |
lib/core/app_config.dart | bannerAdUnitId, interstitialAdUnitId, rewardedAdUnitId (Android and iOS values) |
Where ads appear
- Banner (adaptive, inline) at the end of the Insights and Apps tabs.
- Interstitial only when the user taps "Done" after a completed focus session: every 3rd completed session, at least 15 minutes apart, never on the first day.
- Rewarded on the paywall: watch an ad, get Plus for 24 hours.
- Never on the block screen, during a session, in onboarding, on the PIN screen or for Plus users.
Consent (GDPR, UK, US states, iOS ATT)
The app uses Google's User Messaging Platform: the consent form appears after onboarding when required, and "Ad privacy choices" appears in Settings → Privacy. In AdMob → Privacy & messaging, create a GDPR message, a US state regulations message and (iOS) an IDFA explainer message. Without published messages, ads may not serve in the EEA/UK.
Also create app-ads.txt on your website (AdMob shows the line to add).
16Push notifications
- Users can turn "Tips and news" on or off in Settings → Privacy. Reminders from the native engine are separate.
- Each device subscribes to topics:
all,lang_en/lang_es/lang_bn, andfreeorplus. - Send a campaign: Firebase console → Messaging → New campaign → Notifications, target Topic (for example
freefor an upgrade offer). Under Additional options → Custom data add keyroutewith one of:/paywall,/garden,/rhythm,/protection,/account,/support,/breathing,/insights. - Registration ids are stored in
users/{uid}/devicesfor signed-in users, if you later want to send to one person from a server. - iOS: Apple Developer → Keys → create an APNs key, upload it in Firebase → Project settings → Cloud Messaging. Enable Push Notifications and Background Modes → Remote notifications in Xcode (the entitlement and Info.plist entries are already there).
17Remote Config
Change business settings without an app update. Import remoteconfig.template.json (Firebase console → Remote Config → menu → Publish from file, or firebase deploy --only remoteconfig).
| Key | Default | Meaning |
|---|---|---|
ads_enabled | true | Show ads to free users |
interstitial_every_sessions | 3 | Interstitial after every Nth completed session |
interstitial_min_minutes | 15 | Minimum gap between interstitials |
free_max_schedules / free_max_limits / free_max_mindful | 2 / 3 / 2 | Free-tier limits |
reward_plus_hours | 24 | Plus hours from a rewarded ad |
paywall_default_plan | first plan in plusPlans | Preselected plan on the paywall (any plan id) |
min_build_number | 0 | Builds below this see an "Update available" dialog (0 = off) |
Ship it
18Release build and store listing
Android signing
keytool -genkey -v -keystore android/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Create android/key.properties (never commit it):
storeFile=../upload-keystore.jks
storePassword=YOUR_PASSWORD
keyAlias=upload
keyPassword=YOUR_PASSWORD
flutter build appbundle --release
R8 shrinking is off by default because some plugins call code by name. If you turn it on (isMinifyEnabled in build.gradle.kts), start from android/app/proguard-rules.pro and test the release build on a real device before uploading.
Google Play policy notes
- Foreground service: type
specialUse. In App content → Foreground service permissions, describe: "Blocks the apps the user selected, on the user's own schedule, while the app UI is closed." - Declare and explain Usage access, Display over other apps, notification access and Do Not Disturb access in the listing and privacy policy. The app does not use Accessibility Services or QUERY_ALL_PACKAGES.
- Data safety: declare account info (email, user id – if Firebase sign-in is used), purchase history, crash logs and app interactions (opt-in), advertising id (AdMob). Usage data stays on the device.
- Subscriptions need a privacy policy and terms link in the app (Settings and paywall) – set the URLs in
app_config.dart.
iOS
Select your Team, check Signing & Capabilities (Sign in with Apple, Push Notifications, Background Modes), then flutter build ipa. PrivacyInfo.xcprivacy is included; update it if you add SDKs. In App Privacy answer the same data types as in Google's Data safety form.
19Test checklist
- Blocking: add apps, start a 5-minute session, open a blocked app → block screen.
- Free tier: create a 3rd schedule → paywall with the reason; turn on strict mode → paywall.
- Purchases (license tester / sandbox): buy yearly → "Welcome to Plus!", ads disappear, strict mode unlocks. Reinstall → Restore purchases.
- Tips: buy a tip → thank-you message and supporter badge; buy it again.
- Ads: complete 3 sessions on day 2+ → test interstitial after "Done"; banner at the end of Insights; rewarded on the paywall.
- Sign-in: continue as guest, back up, then Link Google account → same data; delete account.
- Push: send a test message to topic
allwithroute=/paywall, tap it → paywall opens. - Remote Config: set
ads_enabled=false, restart twice → no ads.
Help
20Troubleshooting and FAQ
Blocked apps are not blocked
Open Settings → Protection health. Usage access and Display over other apps must be granted, and battery optimization should be off (some brands need the extra "Background activity" setting the screen links to). Force-stop and uninstall always stop any app blocker – the app tells the user when protection stopped.
Firestore "permission-denied"
Deploy the rules (firebase deploy --only firestore), make sure the user is signed in, and do not add fields the rules do not allow. Entitlements and purchases can only be written by Cloud Functions – that is intentional.
Google sign-in fails (error 10 / DEVELOPER_ERROR)
The SHA-1/SHA-256 of the signing key is missing in Firebase. Add the debug, upload and Play App Signing fingerprints, download google-services.json again and rebuild.
Paywall says "Plans are not available"
The products are not active yet, the ids differ from app_config.dart, the build is not installed from Play (internal testing), or the Google account is not a tester. On iOS check the Paid Apps agreement.
Purchase works but Plus is not granted in server mode
Check Functions logs (firebase functions:log). "Store verification is not available" means the Play Developer API is not enabled or the service account has no Play Console access yet; the app then falls back to on-device verification.
Plus or tips not restored on a new phone
Use the same store account and tap Restore purchases. In server mode, sign in with the same Google/Apple account.
Ads are not showing
New AdMob apps can take hours to serve. In the EEA/UK a published consent message is required. Plus users and rewarded-trial users never see ads. Remote Config ads_enabled may be false. Use test ids or register your device as a test device while developing.
Interstitial ads do not show
By design the interstitial never shows on the first day after install, only after every 3rd completed focus session (tap "Done" on the result) and at least 15 minutes after the previous one. It also does not appear for Plus users or before consent. Lower interstitial_every_sessions / interstitial_min_minutes in Remote Config to test.
Push notifications do not arrive
Android 13+ needs the notification permission (granted in the permissions step). The "Tips and news" switch must be on. iOS needs the APNs key in Firebase and a real device.
Testing with the Firebase Emulator Suite
You can run Auth, Firestore and Functions locally with firebase emulators:start --only auth,firestore,functions. Purchase verification needs the real store APIs, so test purchases against a deployed project.
Build errors after flutter upgrade
Run flutter clean && flutter pub get. See section 19.
21Costs and responsibilities
No accounts, keys or credits are included. You (the buyer) pay for and are responsible for: Google Play Console and Apple Developer fees, the store commission on purchases (Google Play and Apple keep 15–30%), Firebase usage (Spark is free; Blaze is pay-as-you-go and needed for Cloud Functions), AdMob account setup, taxes on your revenue, a privacy policy and terms suited to your business, and compliance with store policies in your countries.
22Updating dependencies
flutter upgrade, thenflutter pub upgrade --major-versionson a separate branch.- Read the changelogs of
in_app_purchase,google_mobile_ads,firebase_*andgoogle_sign_in; they change APIs between major versions. - Reconcile versions: if
flutter pub getreports a conflict, keep the FlutterFire packages on matching releases (they are released together) and letpubspec.locksettle; update theenvironmentsection ofpubspec.yamlto match thesdksinpubspec.lock. - Functions:
cd functions && npm outdated && npm update; check the Node runtime is still supported by Cloud Functions. - Use
flutter pub outdatedto see which packages can move andflutter pub depsto find who pins a version when there is a version conflict. - Run
flutter analyze,flutter testand a release build before shipping.
23Third-party services and credits
| Service / package | Use |
|---|---|
| Firebase (Auth, Firestore, Functions, Messaging, Remote Config, Analytics, Crashlytics) | Optional backend – firebase.google.com |
| Google Mobile Ads (AdMob) + User Messaging Platform | Ads and consent – admob.google.com |
Google Play Billing, Apple StoreKit 2 (in_app_purchase) | Subscriptions, lifetime, tips |
Google Play Developer API (googleapis), @apple/app-store-server-library | Server-side purchase checks |
| Google Sign-In, Sign in with Apple | Optional sign-in |
| flutter_bloc, get_it, go_router, fl_chart, shared_preferences, equatable, intl, uuid, crypto, url_launcher, share_plus, package_info_plus, in_app_review | Open-source packages (BSD/MIT/Apache) – full list and licences in the app: Settings → About → Open source licenses |
| Material Icons | Apache 2.0, bundled with Flutter |
The app uses the system font and emoji; no paid assets, fonts, Lottie files or images from third parties are included. The app icon and illustrations are part of the item.
24Changelog and support
1.0.0
- Initial release.
Support
Email vertexstation@gmail.com with your purchase code. We answer within 2 business days (Bangladesh time). Support covers bugs and questions about the included features and setup steps in this document. Customisation, store submission on your behalf and third-party account problems are not included.
License: Envato Market Regular or Extended License – see envato.com/licenses.