Scrollock Docs v1.0.0

Scrollock documentation

Everything you need to run, re-brand and publish Scrollock: a Flutter app blocker with a native Android engine, in-app purchases, ads, push and an optional Firebase backend.

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).

Home screen
Home
Block screen
Block screen
Insights
Insights
Plus paywall
Plus paywall

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.
The app works fully offline without Firebase. Firebase, ads and purchases are optional layers you switch on in one file.

2Requirements

ToolVersion
Flutter3.47.0 or newer (tested with 3.47.7)
Dart3.13.5 or newer (comes with Flutter)
Android Studio + Android SDKcompileSdk / targetSdk 36, minSdk 24 (Android 7.0)
JDK17
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

  1. Unzip Files/ and open the folder in Android Studio or VS Code.
  2. Get packages and run on a phone or emulator:
    flutter pub get
    flutter run
  3. 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.
  4. 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
  5. iOS: open ios/Runner.xcworkspace in Xcode once, choose your Team in Signing & Capabilities, then flutter 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:

KindWhere
Modelslib/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 / pageslib/features/<feature>/*_screen.dart and lib/monetization/*_screen.dart
Shared widgetslib/core/widgets.dart (cards, buttons, rings, setting rows)
Utils, theme, config, translationslib/core/ (app_config.dart, theme.dart, i18n*.dart)
Routes and app startlib/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

  1. Flutter UI and state – screens in lib/features read and change one FocusCubit (lib/domain/focus_cubit.dart). Everything the user sets up (apps, schedules, limits, sessions, history, settings) is one FocusState saved as JSON in shared_preferences by LocalStore, with a backup copy.
  2. Bridge – after every change the cubit sends the rules to Android over the scrollock/engine MethodChannel (lib/data/engine_bridge.dart, method sync). The same channel returns protection health, usage stats and blocked attempts.
  3. Native engine (Android) – EngineService is 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 of lib/domain/rules_engine.dart) and shows BlockActivity over a blocked app. If a phone blocks that, BlockOverlay is used as a fallback. BootReceiver and Watchdog restart protection.
  4. Firebase (optional) – lib/data/cloud_sync.dart handles 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 / accessWhyNeeded?
Usage access (PACKAGE_USAGE_STATS)Know which app is open, measure screen time and limitsRequired for blocking
Display over other apps (SYSTEM_ALERT_WINDOW)Show the block screen over a blocked appRequired for blocking
Foreground service (specialUse)Keep the engine running while the app is closedRequired for blocking
Notifications (POST_NOTIFICATIONS)Time warnings, reminders, push messages, the service notificationRecommended
Ignore battery optimizationStop the phone from killing the engineRecommended
Start at boot (RECEIVE_BOOT_COMPLETED)Restart protection after a restartAutomatic
Notification access (listener service)Silence notifications of blocked appsOptional (setting)
Do Not Disturb access (ACCESS_NOTIFICATION_POLICY)"Do Not Disturb while focusing"Optional (setting)
InternetFirebase, ads, purchasesAutomatic

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

Focus session
Focus session
Schedules
Schedules
Apps and limits
Apps and limits
Mindful pause
Mindful pause
Focus garden
Focus garden
Protection check
Protection check
Settings
Settings
Dark mode
Dark mode
ScreenFileWhat it does
Onboarding, guided tourfeatures/onboarding/onboarding_screen.dart, features/shell/tour_overlay.dartIntro, daily goal, pick apps, optional sign-in step, then "Grant access" opens the permissions guide; tour of the tabs
Homefeatures/home/home_screen.dartProtection status, current session or schedule, blocked apps, quick start, today's numbers, time left
Start sheet, session, breathingfeatures/session/Mode, duration or "until", allow-list or block list, strict mode; timer with +15 min, breathe and emergency breaks
Schedulesfeatures/schedule/Recurring rules with days, overnight ranges and strict schedules; free limit in AppConfig.freeMaxSchedules
Appsfeatures/apps/Block list, daily time and opens limits, combined social limit, mindful apps
Insightsfeatures/insights/Screen time, weekly chart, streaks, focus score; Plus heatmap and CSV export in plus_history.dart
Gardenfeatures/garden/garden_screen.dartA plant per finished session; rare plants for Plus
Permissions, protection checkfeatures/permissions/Grant access, run a live block test, battery shortcuts per phone brand
Settings, rhythm, PIN, accountfeatures/settings/Strict mode, breaks, warnings, DND, themes, language, privacy, backup, partner, sign-in, deletion
Paywall, tips, invitemonetization/Plus plans from the store, tip jar, invite friends
Native block screenandroid/.../BlockScreen.kt, BlockActivity.ktThe 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:

SettingWhat it does
appName, supportEmail, websiteUrlBrand texts and the "Contact support" address
privacyPolicyUrl, termsUrlShown in Settings and on the paywall (required by Google Play and Apple for subscriptions)
androidPackageId, iosAppStoreIdUsed for "Rate the app", "Share" and the update dialog
enablePurchases, enableTips, enableAds, enablePush, enableAppleSignInMaster switches. Example: ads-only app → enablePurchases = false (every feature becomes free, ads stay)
verifyPurchasesOnServerUse the verifyPurchase Cloud Function when Firebase is configured
plusPlans, tipsYour 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, referralMaxPerYearInvite 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 limits2 schedules, 3 limited apps, 2 mindful apps (also in Remote Config)
AdMob unit idsGoogle's test ids for Android and iOS (replace before release)
Ad pacingInterstitial 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

FileSettingUsed for
lib/core/app_config.dartappNameEvery text inside the app (all languages), share texts, reports
android/app/src/main/res/values/strings.xmlapp_nameLauncher name, notifications and the native block screen on Android
ios/Runner/Info.plistCFBundleDisplayName, CFBundleName, NSUserTrackingUsageDescriptionHome-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

  1. Android: change applicationId and namespace in android/app/build.gradle.kts.
  2. Move android/app/src/main/kotlin/com/vertexstation/scrollock to your path (for example com/yourcompany/yourapp) and update the package line at the top of each Kotlin file.
  3. Search and replace com.vertexstation.scrollock in AndroidManifest.xml, res/xml/shortcuts.xml, lib/core/app_config.dart (androidPackageId) and functions/env.example (ANDROID_PACKAGE_NAME).
  4. iOS: Xcode → Runner target → General → Bundle Identifier.
  5. 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) and icon_foreground.png, then run dart run flutter_launcher_icons. Notification icon: res/drawable/ic_stat_shield.xml.
  • Colors: lib/core/theme.dart → Pal.accents. The teal entry 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.
Check your re-brand: run 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 thisApp update?
Change a priceEdit the price in Play Console (subscription base plan / in-app product) and App Store ConnectNo
Add or remove a free trialPlay Console: add a free-trial offer to the base plan. App Store Connect: add an introductory offer. The paywall shows "7 days free" automaticallyNo
Sell fewer plans (for example only lifetime)Only create those products in the stores. Plans that the store does not return are hidden automaticallyNo
Change the preselected planRemote Config key paywall_default_plan (any plan id), or put that plan first in plusPlansNo (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.jsYes
Change free-tier limitsfreeMaxSchedules, freeMaxLimitedApps, freeMaxMindfulApps in app_config.dart, or Remote Config free_max_schedules / free_max_limits / free_max_mindfulNo (Remote Config)
Make every feature free (ads-only or free app)enablePurchases = falseYes
Hide the tip jar / change tipsenableTips = false, or edit AppConfig.tips and the matching store productsYes
Rewarded "try Plus" lengthrewardPlusHours or Remote Config reward_plus_hoursNo (Remote Config)
Invite-friends rewardreferralDays / referralMaxPerYear in app_config.dart and the same constants in functions/index.jsYes

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),
];
  1. 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 for PlanKind.lifetime).
  2. 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.dart and i18n_bn.dart.
  3. 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).
  4. Add every plan id to SUBSCRIPTIONS or LIFETIME at the top of functions/index.js, then deploy the functions. flutter test fails if you forget.
Where the prices come from: the paywall reads the price, currency and trial from the store at runtime (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.

FeatureFile
More schedules than the free limitfeatures/schedule/schedule_screen.dart
Strict modefeatures/settings/settings_screen.dart, features/session/start_sheet.dart, features/schedule/schedule_editor_screen.dart
More app limits / mindful apps than the free limitfeatures/apps/apps_screen.dart
History heatmap and CSV exportfeatures/insights/plus_history.dart
Automatic backup, accountability partnerfeatures/settings/account_screen.dart
Color themesfeatures/settings/settings_extras.dart
Rare garden plantsfeatures/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)

  1. Create a project at console.firebase.google.com. Analytics can stay on.
  2. Authentication → Sign-in method: enable Google, Anonymous and (for iOS) Apple. Set a support email.
  3. 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). Download google-services.json into android/app/. Download it after enabling Google sign-in so it contains the web client id.
  4. Add app → iOS with your bundle id. Download GoogleService-Info.plist, drag it into Runner in Xcode (Copy items if needed). Copy its REVERSED_CLIENT_ID into ios/Runner/Info.plist, replacing com.googleusercontent.apps.REPLACE-WITH-YOUR-REVERSED-CLIENT-ID.
  5. Firestore Database → Create database (production mode, pick a location close to your users).
  6. 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?

  1. Run the app with your real google-services.json and open Settings → Cloud backup → Continue as guest. A profile card ("Guest") appears: Authentication works.
  2. 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.
  3. 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.
  4. Push: in the console open Messaging → New campaign, send to topic all. The notification arrives (app in background).
  5. 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.

Data model: 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:
    1. Apple Developer → Identifiers → your App ID → enable Sign In with Apple.
    2. The entitlement is already in ios/Runner/Runner.entitlements. In Xcode → Signing & Capabilities you should see "Sign in with Apple".
    3. 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 cleanupUser function 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

FeatureFreePlus
Focus sessions, block screen, widget, tile, reminders, insights (7 days)✔✔
Schedules2unlimited
Apps with time / open limits3unlimited
Mindful-open apps2unlimited
Strict mode (sessions and schedules)–✔
History heatmap, CSV export–✔
Automatic backup, accountability partnermanual backup✔
Color themes, rare garden plants–✔
Adsyesnone

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

  1. Upload a signed build to the internal testing track (billing only works for apps uploaded to Play).
  2. 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.
  3. Monetize → Products → In-app products: create your lifetime plan (shipped id plus_lifetime) and the tip products from AppConfig.tips (tip_small, tip_medium, tip_large). Tips are consumed automatically after purchase, so they can be bought again.
  4. Setup → License testing: add your Google account so test purchases are free.

App Store Connect

  1. 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.
  2. Create the lifetime plan as Non-Consumable and the tips as Consumable.
  3. 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).

FunctionTriggerJob
verifyPurchasecallableChecks a purchase token (Play Developer API) or StoreKit 2 signed transaction (Apple library) and grants Plus
playNotificationsPub/Sub topic play-billingRenewals, cancellations, refunds from Google Play RTDN
appleNotificationsHTTPSApp Store Server Notifications V2 (renewals, refunds, revocations)
cleanupUserAuth deleteRemoves entitlements, invite codes and detaches purchases when an account is deleted
getReferralCode / redeemReferralcallableInvite 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

  1. Google Cloud console (same project) → enable the Google Play Android Developer API.
  2. Play Console → Users and permissions → Invite new user: the Functions service account (PROJECT_ID@appspot.gserviceaccount.com or 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.
  3. Real-time notifications: Google Cloud → Pub/Sub → create topic play-billing, grant google-play-developer-notifications@system.gserviceaccount.com the 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.

If the functions are not deployed, the app falls back to the store's own signed purchase list on the device, so purchases still work on the free Spark plan – just without server checks and renewal webhooks.

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 getReferralCode and redeemReferral Cloud Functions (Blaze plan) and stored in referrals, referralCodes and users/{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_YEAR and REFERRAL_NEW_ACCOUNT_DAYS in functions/index.js and the matching values in app_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

The project ships with Google's official test ids. They show "Test Ad" and never earn money. Replace all of them before release.
WhereWhat to replace
android/app/src/main/AndroidManifest.xmlcom.google.android.gms.ads.APPLICATION_ID (Android app id ca-app-pub-…~…)
ios/Runner/Info.plistGADApplicationIdentifier (iOS app id)
lib/core/app_config.dartbannerAdUnitId, 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, and free or plus.
  • Send a campaign: Firebase console → Messaging → New campaign → Notifications, target Topic (for example free for an upgrade offer). Under Additional options → Custom data add key route with one of: /paywall, /garden, /rhythm, /protection, /account, /support, /breathing, /insights.
  • Registration ids are stored in users/{uid}/devices for 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).

KeyDefaultMeaning
ads_enabledtrueShow ads to free users
interstitial_every_sessions3Interstitial after every Nth completed session
interstitial_min_minutes15Minimum gap between interstitials
free_max_schedules / free_max_limits / free_max_mindful2 / 3 / 2Free-tier limits
reward_plus_hours24Plus hours from a rewarded ad
paywall_default_planfirst plan in plusPlansPreselected plan on the paywall (any plan id)
min_build_number0Builds 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

  1. Blocking: add apps, start a 5-minute session, open a blocked app → block screen.
  2. Free tier: create a 3rd schedule → paywall with the reason; turn on strict mode → paywall.
  3. Purchases (license tester / sandbox): buy yearly → "Welcome to Plus!", ads disappear, strict mode unlocks. Reinstall → Restore purchases.
  4. Tips: buy a tip → thank-you message and supporter badge; buy it again.
  5. Ads: complete 3 sessions on day 2+ → test interstitial after "Done"; banner at the end of Insights; rewarded on the paywall.
  6. Sign-in: continue as guest, back up, then Link Google account → same data; delete account.
  7. Push: send a test message to topic all with route=/paywall, tap it → paywall opens.
  8. 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

  1. flutter upgrade, then flutter pub upgrade --major-versions on a separate branch.
  2. Read the changelogs of in_app_purchase, google_mobile_ads, firebase_* and google_sign_in; they change APIs between major versions.
  3. Reconcile versions: if flutter pub get reports a conflict, keep the FlutterFire packages on matching releases (they are released together) and let pubspec.lock settle; update the environment section of pubspec.yaml to match the sdks in pubspec.lock.
  4. Functions: cd functions && npm outdated && npm update; check the Node runtime is still supported by Cloud Functions.
  5. Use flutter pub outdated to see which packages can move and flutter pub deps to find who pins a version when there is a version conflict.
  6. Run flutter analyze, flutter test and a release build before shipping.

23Third-party services and credits

Service / packageUse
Firebase (Auth, Firestore, Functions, Messaging, Remote Config, Analytics, Crashlytics)Optional backend – firebase.google.com
Google Mobile Ads (AdMob) + User Messaging PlatformAds 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-libraryServer-side purchase checks
Google Sign-In, Sign in with AppleOptional 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_reviewOpen-source packages (BSD/MIT/Apache) – full list and licences in the app: Settings → About → Open source licenses
Material IconsApache 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.