Android App
This guide is for developers building or customizing the LeadHub Android companion app. The app source code is written in Kotlin and follows standard Android development patterns.
Requirementsโ
- Android Studio (latest stable release)
- JDK 17 or later
- Android SDK โ minimum API level 26 (Android 8.0)
- A LeadHub instance with a valid HTTPS URL and an active API key
Project Setupโ
- Open the
android/folder from your LeadHub purchase in Android Studio. - Let Gradle sync and download dependencies automatically.
- Open
app/src/main/res/values/config.xml(or the equivalent config file in the project) and set your default instance URL if you want to pre-fill it for users.
Architectureโ
The app uses a standard Android architecture:
- Retrofit for HTTP calls to the LeadHub REST API
- ViewModel + LiveData for UI state management
- Room for local caching of leads between sessions
- Firebase Cloud Messaging (FCM) for push notifications
All API calls use the Authorization: Bearer {api_key} header pattern. The API key is stored in Android's EncryptedSharedPreferences.
Authentication Flowโ
- The user enters their LeadHub instance URL and API key on the login screen.
- The app calls
GET /api/v1/healthto verify the instance is reachable. - It then calls
GET /api/v1/users/me(or equivalent) to verify the key is valid and fetch the user profile. - The URL and key are stored in EncryptedSharedPreferences for subsequent launches.
Push Notificationsโ
Push notifications are delivered through Firebase Cloud Messaging. To enable them:
- Create a Firebase project at console.firebase.google.com.
- Add an Android app to the project with your app's package name.
- Download
google-services.jsonand place it in theapp/directory. - In your LeadHub backend configuration, set
FCM_SERVER_KEYto your Firebase server key.
The app registers its FCM token with the LeadHub backend when the user logs in.
Building for Releaseโ
- Generate a signing keystore:
keytool -genkey -v -keystore leadhub.keystore -alias leadhub -keyalg RSA -keysize 2048 -validity 10000 - Add signing config to
app/build.gradle. - Build a signed APK or AAB via Build โ Generate Signed Bundle/APK.
- Upload the AAB to the Google Play Console.
API Endpoints Usedโ
The app uses these LeadHub API endpoints. All require a valid Bearer token:
| Endpoint | Purpose |
|---|---|
GET /api/v1/health | Verify instance connectivity |
GET /api/v1/leads | Load leads list |
GET /api/v1/leads/{id} | Load lead detail |
PATCH /api/v1/leads/{id} | Update lead status or stage |
POST /api/v1/leads/{id}/tags | Add tag to lead |
GET /api/v1/pipelines | Load pipeline list for stage picker |
Minimum Required API Key Scopesโ
| Scope | Reason |
|---|---|
read:leads | View leads |
write:leads | Update lead status, stage, and tags |
read:pipelines | Populate the pipeline stage picker |