Policy Hub Android app
How to set up, build and publish the customer app for Android: connect it to your website, brand it, add push notifications and release it on Google Play.
Overview
The Policy Hub Android app is the companion of the Policy Hub SaaS website. Customers see their policies, pay premiums, file claims, chat with their agent and keep a policy card on their phone.
One app serves every agency on your platform: the customer finds their agency by name, company code or QR code, and signs in. You can also build an own-brand app for a single agency.
What is in the package
| Item | What it is |
|---|---|
android_app/ | The complete Flutter project for Android (source code) |
android_app/README.md | Setup, build, push notification and store publishing steps |
android_app/docs/mobile-api.md | Reference of the customer API the app uses |
lib/ | The app code (screens, API client, session, helpers) |
android/ | The Android project files |
Features
Everything a policyholder needs, in one app.
| Feature | What it does |
|---|---|
| Find your agency | Search by name or city, type the company code, or scan the QR code from the agency's website. One app for many agencies. |
| Sign in | Email and password, or a 6-digit code sent to the customer's email, depending on what the agency allows. |
| Home | Policies in force, yearly premium, what is owed, late payments, the next renewal, open claims, KYC status and the agent's contact details. |
| My policies | Every policy with status, cover, insured people, nominees, instalments, payments, documents and a change history. Certificate as a PDF. |
| Policy cards | A digital card for each policy that opens even with no network (the last copy is kept in the phone's secure storage and removed at sign-out). |
| Plans | The agency's plans with search and filters, full details, a premium estimator by term (tax included), side-by-side comparison of up to 3 plans, and "I want this plan" which sends the agent a quote request. |
| Payments due | Late payments, upcoming instalments and policies to renew within 60 days in one place, each with a Pay button. PDF receipts for every payment. |
| Pay | Opens the agency's secure payment page (Stripe or Razorpay) in the phone's in-app browser. No card details pass through the app. |
| Claims | File a claim on a policy, see the documents it needs, upload photos or PDFs (up to 10 MB) and follow every status step. |
| Chat with the agent | Messages to the agency or the customer's own agent, with pictures (shown inline), PDFs and text files up to 5 MB. Call, WhatsApp or email the agent from a bottom sheet. |
| Ask my agency | Callback, renewal help, quote and nominee change requests, with the agency's reply. Download all personal data, or ask for it to be erased. |
| Documents (KYC) | Upload an ID photo or PDF and see whether it is approved, in review or not accepted. |
| Inbox and push | Reminders and updates in an inbox, plus phone notifications when push is set up. |
| Assistant | Ask questions about their own policies, claims and payments when the agency switches the assistant on. |
| Refer a friend | Personal referral link and the people referred. |
| Security and look | Fingerprint or face unlock, dark mode, a list of phones signed in with remote sign-out, change password, sign out of all devices. Several agencies on one phone with Switch company. |
Not included
- Owner, agent and staff tools. Agencies manage everything on the website; the app is for customers only.
- Card payments inside the app. Payment opens the agency's own gateway page.
Requirements
Your computer (to build the app)
- Flutter (a current stable release whose Dart is 3.13 or newer)
- Windows, macOS or Linux with Android Studio and the Android SDK
- About 10 GB of free disk space
Phones
- Android phones and tablets supported by your Flutter version
Accounts
- Google Play developer account (one-time fee) to publish
- Optional: a Firebase project for push notifications
Website
- Policy Hub SaaS v1.7 or newer on https
- The agency's website published (the company code is the name in its address,
/site/<code>) - Email (SMTP) set up if you want emailed sign-in codes
- The cron job running, for reminders and push
Install Flutter & Android Studio
- Install FlutterFollow docs.flutter.dev for your system and add
flutterto your PATH. - Install Android StudioInstall it with the Android SDK, the command-line tools and an emulator image. Accept the licences:
flutter doctor --android-licenses. - CheckRun
flutter doctor. Every line for Flutter and Android should have a green tick.
Prepare the website
Do this once, before you test the app.
- Use httpsThe app talks to your website over https. A debug build also accepts plain http for testing.
- Publish the agency's websiteUnder Website the agency switches the website on. The company code is the name in the website address.
- Open Mobile AppsThe owner's Mobile Apps page shows the QR code, the company code and the page customers use to get the app. The super admin saves the store links there once the app is published.
- Run the migrationAfter uploading the website, run
php artisan migrateso the chat tables and permissions exist. - Set up emailUnder Settings → Email Settings. It is used for emailed sign-in codes and reminders.
- Add the cron line
* * * * * cd /path/to/site && php artisan schedule:run >> /dev/null 2>&1so reminders and push messages go out. - Create a test customerAdd a customer on the website, or let one register online. The customer signs in to the app with the same email and password.
Set up the project
- UnzipUnzip
policy-hub-android-v1.0.0.zipand open theandroid_appfolder in Android Studio or VS Code. - Get the packagesIn that folder run
flutter pub get. - Check the codeOptional:
flutter analyzeandflutter test.
cd android_app flutter pub get
Run on a phone or emulator
Pass your website address when you run or build, so customers never type it.
On a real phone
- Turn on USB debuggingSettings → About phone → tap Build number seven times, then Developer options → USB debugging.
- Connect and checkPlug the phone in and run
flutter devices. - Run
flutter run --dart-define=API_BASE_URL=https://yourdomain.com
On the emulator
Start an emulator from Android Studio, then run the same command. To reach a website on your own computer the emulator uses http://10.0.2.2/... instead of localhost.
flutter run --dart-define=API_BASE_URL=http://10.0.2.2/your-folder/main_file
Testing against a local website (http)
A debug build accepts plain http://. Release builds need https://.
Quick check without a phone
This signs in and out against your website using a customer account and reads the data the app needs:
dart run tool/smoke.dart https://yourdomain.com company-code customer@example.com password
API_BASE_URL out and the first screen also asks for the server address. That is handy while testing.How customers connect
| Way in | How it works |
|---|---|
| Search | The customer types the agency's name or city. |
| Company code | The customer types the code (the name in the agency's website address, /site/<code>). |
| QR code | The QR code is on the agency's Get our app page and in its website footer. Scanning it opens the app on that agency; the app asks Connect to <company> at <host>? before it trusts the address. |
| Link | A policyhub://connect link, or a link from the agency's page, opens the app on that agency. |
After that the sign-in screen shows the agency's logo and name, and the whole app takes on its colour. A phone can hold several agencies (More → Switch company).
An app for one agency only
Build with the agency's code as well and the app has no company screen:
flutter build apk --dart-define=API_BASE_URL=https://yourdomain.com --dart-define=COMPANY=company-code
API_BASE_URL is built in, codes and links cannot point the app to a different server.Sign-in & security
| Topic | What happens |
|---|---|
| Sign-in | Email and password, or an emailed 6-digit code when the agency allows it. |
| Token storage | The sign-in token is kept in the Android Keystore, not in plain files. |
| Lock | Under More the customer can turn on Unlock with fingerprint or face. The app asks when it opens and after 30 seconds away. Turning it on asks once, so a lock the person cannot open is never enabled. |
| Policy cards | The offline copy of the policy cards is kept in secure storage and deleted when the customer signs out. |
| Signed-in phones | More → Phones signed in lists every phone signed in to the account and can sign any of them out. |
| Password change | Changing the password signs the app out everywhere. Sign out of all devices is in the app. |
| First sign-in | A customer created by staff with a typed password is asked to choose their own. |
| Idle sign-out | An app that is not used for 90 days is signed out (MOBILE_TOKEN_IDLE_DAYS on the server). |
| Update and maintenance | The server can require a minimum app version (MOBILE_MIN_APP_VERSION) or show a maintenance message (MOBILE_MAINTENANCE). |
Branding & customisation
Changes that need no new build (from the website)
- The agency's logo, name and colour: the app takes them from the agency's website settings.
- The QR code, company code and store links on the Mobile Apps page.
- Whether emailed codes and the assistant are available.
Changes in the code (then build again)
| What | Where |
|---|---|
| App name shown on the phone | Policy Hub in android/app/src/main/AndroidManifest.xml (android:label) |
| App id | com.policyhub.policy_hub_app — change applicationId and namespace in android/app/build.gradle.kts. Do this before you publish. |
| Colour | buildTheme() in lib/main.dart (one seed colour) |
| Icon and logo | assets/icon.png, assets/icon_foreground.png, assets/logo.png. Replace them, then run dart run flutter_launcher_icons. |
| Version | version in pubspec.yaml (now 1.0.0+1) and AppConfig.appVersion in lib/config.dart |
Push notifications (Firebase)
Optional. Without it the app works and the in-app inbox still fills up; only the phone pop-ups are missing.
- Create a Firebase projectAt console.firebase.google.com add an Android app with your application id.
- Add the fileDownload
google-services.jsonand put it inandroid/app/. The build switches push on when the file is there. - Connect the serverProject settings → Service accounts → generate a private key. On the server put its path in
.envasFCM_CREDENTIALS=/path/key.json. - Check the schedulerThe Laravel cron line must be running; reminders are sent from it.
When customers are notified
- Before and after an instalment or renewal is due (reminders)
- A payment is received
- A claim changes status or needs a document
- The agency replies in the chat
- A request is answered
Signing key & build the release
1. Create a signing key (once)
keytool -genkey -v -keystore ~/policy-hub.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
2. Tell the build where the key is
Create android/key.properties with:
storeFile=/home/you/policy-hub.jks storePassword=******** keyAlias=upload keyPassword=********
3. Build
flutter build appbundle --dart-define=API_BASE_URL=https://yourdomain.com
Upload build/app/outputs/bundle/release/app-release.aab to Google Play.
A test APK to share
flutter build apk --split-per-abi --dart-define=API_BASE_URL=https://yourdomain.com
This makes smaller files, one for each processor type, in build/app/outputs/flutter-apk/.
Publish on Google Play
- Developer accountRegister at play.google.com/console and pay the one-time fee.
- Create the appAll apps → Create app. Choose the name, language, App and Free.
- Store listingAdd the name, short and full description, the app icon (512×512), a feature graphic (1024×500) and phone screenshots.
- App contentFill in the privacy policy link, ads declaration, data safety form (see below), target audience and content rating.
- Upload and releaseProduction → Create new release → upload the
.aab→ add release notes → review and roll out. New developer accounts may be asked to run a closed test first. - Add the link to your websiteCopy the Play Store link into the website's Mobile Apps page (super admin) so the Get our app page shows the store button.
Updates
Raise the version in pubspec.yaml (for example 1.0.1+2; the number after + must go up every upload), build again and upload a new release.
Privacy & data safety
Use this when you fill in the store forms.
Android permissions used
| Permission | Why |
|---|---|
| INTERNET | Talk to your website |
| POST_NOTIFICATIONS | Show push notifications (Android 13+) |
| USE_BIOMETRIC | Fingerprint or face unlock |
The camera and photo picker are used through the system picker when the customer uploads a document or sends a picture, so no extra permission is declared.
Data the app handles
| Data | Used for | Shared |
|---|---|---|
| Name, email, phone | Account and contact with the agency | Only with the customer's own agency |
| Policy, claim and payment details | Showing policies and handling claims | Only with the customer's own agency |
| Messages, documents and photos the customer chooses | Chat, claims and KYC checks | Only with the customer's own agency |
| Device push token (if push is on) | Sending notifications | Firebase Cloud Messaging |
Settings reference
android/app/src/main/AndroidManifest.xml
- The three permissions above
android:label: the app name- A
policyhub://connectlink so a scanned QR code opens the app applicationIdandnamespaceinandroid/app/build.gradle.kts; the Firebase plugin is applied only ifgoogle-services.jsonexists
Code structure
| Path | What it holds |
|---|---|
lib/main.dart | App start, theme (light and dark) and routing |
lib/config.dart | Build-time settings: API_BASE_URL, COMPANY, version |
lib/push.dart | Push notification setup |
lib/api/api_client.dart | Every call to the customer API |
lib/state/session.dart | Signed-in agencies, tokens, lock, theme, offline policy cards |
lib/screens/ | Company, login, scan, shell (tabs), dashboard, policies, policy detail, policy cards, plans and plan detail, payments due, claims, file a claim, requests, KYC, chat, notifications, assistant, referral, signed-in phones, more, switch company, change password, lock |
lib/util/ | Formatting, files, payment page, picker, QR parsing |
lib/widgets/ | Shared pieces (company logo, confirm dialog, loaders) |
test/ | Unit and widget tests, and a screenshot renderer |
tool/smoke.dart | Command-line check of the app against your website |
The iPhone project in the other package has identical lib/ code; when you change one, make the same change in the other.
Updating to a new version
- Back upKeep your own changes (name, id, icons, colours) somewhere safe.
- ReplaceUnzip the new package and copy your changes over it.
- Raise the versionIncrease
versioninpubspec.yaml. - Build and uploadBuild the release again and upload it to Google Play.
Update the website to the version the new app needs first.
Troubleshooting & FAQ
| Problem | Try this |
|---|---|
| The app cannot find my agency | Check the company code, that the agency's website is published, and that the address is https and reachable from the phone. |
| "Could not connect to the server" | Check API_BASE_URL (https for release builds) and that the website opens in the phone's browser. |
| No emailed code arrives | Set up and test Settings → Email Settings on the website, and check the spam folder. |
| The QR code does not open the app | Install the app first, then scan from inside the app (Scan QR on the first screen). |
| No push notifications | Check google-services.json is in android/app/, FCM_CREDENTIALS is set on the server and the cron job runs. |
| Chat or Plans screens are missing | Run php artisan migrate on the website, and make sure the customer role has the "use chat" permission. |
| Customer is asked to change password | They were created with a typed password. They choose their own once and carry on. |
| Payment page does not open | The agency must have Stripe or Razorpay switched on in the website's payment settings. |
| Build fails after changing packages | Run flutter clean, flutter pub get and build again. |
Do I need one app per agency?
No. One app serves every agency; the customer picks theirs. You can also build an own-brand app for a single agency.
Can owners and agents use the app?
No, it is for customers. Agencies and agents use the website.
Where is the data stored?
On your website's server. The app keeps the sign-in token, and the offline policy cards, only on the phone.
How do payments work?
The app opens the agency's own payment page in a secure in-app browser. No card details pass through the app.
Can I publish under my own name?
Yes. Change the name, id and icons, then publish with your own Google Play account.
Support
Open a ticket at support.smartwebinfotech.com with your purchase code, the app version, what you did and what you saw.