Prompt
How do I support both iOS and Android with one backend?
Latest observation
The usual way is: build one backend API that both apps call. iOS and Android stay separate clients, but they share the same server, database, auth, and business logic.
Typical architecture
- Mobile apps: iOS app + Android app
- Backend: one API service
- Database: one shared database
- Auth: one identity system
- Shared logic: validation, permissions, business rules
What the backend should provide
Design the backend as a platform API, not as an app-specific backend:
- REST or GraphQL API
- Authentication
- JWT, OAuth2, or session tokens
- Apple Sign-In / Google Sign-In if needed
- Versioning
- e.g.
/v1/...
- e.g.
- Platform-specific handling
- device tokens for push notifications
- app version checks
- feature flags / remote config
- File/media storage
- S3, GCS, Azure Blob, etc.
- Push notifications
- APNs for iOS
- FCM for Android
- backend stores device tokens and sends via the right service
Good practices
1. Keep the API device-agnostic
Don’t expose “iOS endpoints” and “Android endpoints” unless truly necessary. Use the same resources and actions for both.
2. Version your API
Mobile apps update slowly, so old versions will exist in the wild. Use:
/api/v1/.../api/v2/...
This helps you evolve the backend without breaking old app versions.
3. Use one source of truth
Business rules should live in the backend whenever possible:
- pricing
- permissions
- eligibility
- ordering logic
- content visibility
That way both apps behave consistently.
4. Plan for offline and sync if needed
If the apps need offline mode, add:
- local caching
- sync endpoints
- conflict resolution
5. Handle platform differences separately in the client
Examples:
- UI conventions
- navigation
- permissions prompts
- push notification setup
- in-app purchase APIs
The backend should not care about UI differences unless necessary.
Common tech stacks
You can choose almost any backend stack:
- Node.js / Express / NestJS
- Python / Django / FastAPI
- Java / Spring Boot
- Go / Gin / Fiber
- Ruby on Rails
- .NET / ASP.NET Core
For APIs:
- REST is simplest and most common
- GraphQL is useful if the clients need flexible querying
Example flow
- User logs in on iOS or Android
- App sends credentials to backend
- Backend returns auth token
- App uses token for all subsequent requests
- Backend reads/writes the same database for both platforms
If you want to move fast
A common setup is:
- Backend: Firebase, Supabase, or custom API
- Auth: Firebase Auth / Cognito / Auth0
- DB: Postgres
- Push: FCM + APNs
- Storage: S3-compatible bucket
In short
You don’t build two backends. You build one backend API and make both mobile apps use it.
If you want, I can also show:
- a sample API design for iOS + Android
- a recommended folder structure for the backend
- how to handle push notifications for both platforms