Skip to main content

Part of topic: Backend & Modular Systems, Kotlin Multiplatform & Mobile Engineering, Full-Stack Systems Design

Building a Mobile Token Retrieval Application: Production Android for Utility Customers

Building a Mobile Token Retrieval Application: Production Android for Utility Customers

November 1, 2026 4 min read Android, Kotlin, Mobile Development, API Design, Production Deployment, Utility Tech

Building a Mobile Token Retrieval Application: Production Android for Utility Customers is a Developer Journal article by Ancel Ajanga on https://ancel.co.ke. Engineering an Android application for prepaid utility customers: reliable token retrieval, upstream credential isolation, honest handling of upstream limits, and rollout lessons. It focuses on: Prepaid electricity customers who purchase power tokens often experience severe stress when telecom SMS delivery delays prevent receipts from arriving. Ancel Ajanga…

Engineering an Android application for prepaid utility customers: reliable token retrieval, upstream credential isolation, honest handling of upstream limits, and rollout lessons.

Who this is for

Mobile engineers, backend developers, and product teams building reliable customer-facing utility applications operating over cellular networks in emerging markets.

Problem

Prepaid electricity customers who purchase power tokens often experience severe stress when telecom SMS delivery delays prevent receipts from arriving. They need an immediate, dependable way to retrieve their 20-digit token numbers without relying on delayed telecom SMS gateways.

Business outcome

A lightweight production Android application rolled out on 1 November 2026, allowing customers to query their meter number and immediately receive their 5 most recent token purchases with zero SMS dependency.

Metrics

  • Production rollout on 1 November 2026
  • Retrieval of the 5 most recent token records, matching the upstream system limit
  • Upstream credentials kept on the backend and never shipped in the app

When a customer's prepaid electricity runs out at 9:00 PM and their purchased power token does not arrive via SMS due to telecom network congestion, every additional minute of waiting creates intense frustration. The customer has already paid their money, their lights are out, and they are left waiting in the dark with no immediate way to view their 20-digit prepaid meter token.

Building a customer-facing mobile retrieval application sounds straightforward on the surface until you confront the engineering realities of utility integration: you cannot expose upstream vendor credentials to client devices, you cannot subject an existing system of record to unthrottled mobile traffic, and you cannot assume customers enjoy fast, stable cellular data.

This article details how I engineered, tested, and rolled out the **Mobile Token Retrieval Experience**, a production Android application launched on **1 November 2026**.

The Real Problem: Telecom Delivery Gaps in Utility Distribution

Prepaid utility distribution in emerging markets relies heavily on cellular aggregators: 1. Customer purchases tokens via mobile money (M-Pesa). 2. The aggregator processes the purchase and sends a transaction confirmation to the utility vendor. 3. The vendor generates the 20-digit meter token. 4. An automated SMS gateway attempts to deliver the token receipt to the customer's mobile number.

During peak evening purchase windows or telecommunication outages, the automated SMS delivery pipeline often backs up. Customers are left stranded without power despite having successfully completed their purchase.

The objective was clear: **Give customers an independent, on-demand Android application where they can enter their meter number or account reference and immediately retrieve their prepaid tokens—with zero reliance on SMS delivery.**

Architectural Approach: Gateway Isolation and Mobile Client

Exposing the utility vendor's proprietary SOAP or internal REST endpoints directly to an untrusted public Android app would be an architectural and security failure: - Client-side decompilation would leak internal infrastructure URLs and authentication tokens. - Spikes in mobile traffic could easily overwhelm the legacy database of record. - Unsanitized mobile queries could expose sensitive customer account records.

I designed a **Two-Tier Architecture**:

Android App]  --> (HTTPS / Token Auth) --> [Intermediary Gateway] --> [System of Record]

1. **The Intermediary Backend Gateway**: - Acts as a security bastion, terminating public mobile requests and verifying client integrity. - Holds the proprietary upstream credentials securely in encrypted environment vaults. - Validates and sanitizes meter numbers before forwarding requests upstream. - Enforces IP-based and device-based rate limits to prevent brute-force enumeration of customer meters. - Normalizes legacy vendor response formats into clean, lightweight JSON payloads for mobile consumption.

2. **The Native Android Application**: - Engineered in **Kotlin** with a focus on speed, low battery consumption, and minimal APK bundle size. - Implements local **Room/SQLite caching** so that previously retrieved tokens remain viewable even if the user loses cellular signal completely while walking back to their meter box. - Features a high-contrast, readable UI designed for stressful low-light conditions.

Factual Constraints: The 5-Record Window

A critical engineering responsibility is maintaining complete honesty between what an upstream system supports and what the user interface promises.

During development, we evaluated whether to support multi-month historical token archives, date-range filtering, and year-long consumption exports. However, an audit of the upstream vendor interface revealed an immovable constraint: **the upstream system of record only returns the 5 most recent transactions and does not support date-range queries or pagination parameters.**

Rather than presenting a misleading date-picker interface that would fail or invent fake history, the mobile application is intentionally designed around reality: - The UI explicitly informs the user that it retrieves their **5 most recent token transactions**. - Large, high-visibility copy buttons allow the customer to copy the 20-digit token number with a single tap. - Clear breakdown cards display the token units, purchase amount, date, and receipt number.

Production Android Rollout

Deploying an application to Google Play for real utility customers requires rigorous engineering checks: - **APK Optimization**: Optimized resource assets and ProGuard/R8 code shrinking to keep the download size under 8MB, ensuring fast installs even over slow 3G connections. - **Defensive Error Handling**: Clear, friendly error messaging when meter numbers are entered with typos or when upstream services are undergoing scheduled maintenance. - **Rollout Verification**: The application was launched to production on **1 November 2026** and is actively used by customers to retrieve their tokens reliably.

Key Engineering Takeaways

1. **Never Expose Upstream Backends to Mobile Clients**: Always place an intermediary gateway between client devices and internal systems of record to handle rate limiting, credential isolation, and payload normalization. 2. **Design for Low-Light, High-Stress Contexts**: When utility customers use your app, their lights are likely off and their battery is low. Prioritize instant startup, high contrast, and one-tap copy functionality over flashy animations. 3. **Respect Upstream Constraints Honestly**: If an upstream API only supports 5 records, design a world-class 5-record experience rather than building broken pagination workflows.

Review the Mobile Token Retrieval Case Study or explore the [Project Page](/projects/mobile-token-retrieval-experience). If you have questions about Android engineering or utility systems, [feel free to get in touch](/contact).

Trade-offs

Factual constraint: Upstream vendor system of record only returns the 5 most recent transactions without pagination or date filtering; rather than presenting a misleading multi-month search interface, the UI honestly displays the verified 5-record window.

Challenges faced

Isolating upstream credentials behind an intermediary gateway, optimizing APK bundle size for low-end Android devices, and providing offline caching for previously fetched tokens.