Skip to content

jasiri51/smsrelay

 
 

Repository files navigation

SMS Relay - Production Ready Mobile App

A secure, efficient SMS relay mobile application that receives SMS requests via Firebase Cloud Messaging and forwards them automatically. Perfect for SMS forwarding services.

Features

One-Time Login - Secure email/password authentication
Firebase Integration - Real-time SMS delivery via FCM (no polling)
SMS Management - Local database tracking of all SMS (sent/failed/pending)
Beautiful UI - Material Design 3 with modern layouts
Offline Support - Works without active internet (buffering capability)
Security - Encrypted authentication tokens, secure API communication
Production Ready - Error handling, logging, crash reporting setup
Zero Polling - Event-driven architecture using Firebase

App Flow

Splash Screen (Check Login)
    ↓
[Logged Out?] → Login Activity → Server Authentication → FCM Token Register
    ↓
[Logged In?] → Dashboard Activity (Main)
    ↓
← Receives SMS via Firebase Cloud Messaging
← Auto-sends SMS to recipient
← Stores record in local database
← Updates server with status

Dashboard Features:
- Welcome message with user email
- Total sent/failed SMS count
- Recent SMS list (3 items)
- View full SMS history button
- Logout button

SMS Status Activity:
- Filter by All/Sent/Failed
- Full SMS history with timestamps
- Message content preview
- Recipient numbers
- Status indicators

Architecture

app/
├── auth/
│   ├── AuthManager.kt          (Authentication logic)
│   └── LoginActivity.kt         (Login UI)
├── core/
│   ├── AppConstants.kt          (Constants)
│   ├── AppUtils.kt              (Utility functions)
│   └── DeviceInfo.kt            (Device information)
├── data/
│   ├── database/
│   │   ├── AppDatabase.kt       (Room database)
│   │   └── SmsDao.kt            (Data access objects)
│   ├── entity/
│   │   └── SmsEntity.kt         (Database entity)
│   ├── model/
│   │   ├── SmsRecord.kt         (Domain model)
│   │   └── User.kt              (User model)
│   └── repository/
│       └── SmsRepository.kt     (Data repository)
├── fcm/
│   ├── FcmManager.kt            (FCM management)
│   └── MyFirebaseService.kt     (FCM message handling)
├── network/
│   ├── ApiClient.kt             (Retrofit setup)
│   ├── ApiService.kt            (API endpoints)
│   └── NetworkManager.kt        (Network operations)
├── sms/
│   ├── SmsManager.kt            (SMS sending logic)
│   └── SmsStatusReceiver.kt     (SMS delivery reports)
├── storage/
│   └── StorageManager.kt        (SharedPreferences wrapper)
├── ui/
│   ├── BaseActivity.kt          (Base activity class)
│   ├── DashboardActivity.kt     (Main dashboard)
│   ├── SmsStatusActivity.kt     (SMS history view)
│   ├── SmsAdapter.kt            (RecyclerView adapter)
│   └── SplashActivity.kt        (Splash screen)
└── SmsRelayApp.kt              (Application class)

res/
├── layout/
│   ├── activity_splash.xml
│   ├── activity_login.xml
│   ├── activity_dashboard.xml
│   ├── activity_sms_status.xml
│   └── item_sms.xml
└── values/
    ├── colors.xml
    ├── dimens.xml
    ├── strings.xml
    └── themes.xml

Setup Instructions

1. Clone and Open in Android Studio

git clone <repository-url>
cd smsrelay
open build.gradle.kts in Android Studio

2. Configure Firebase

  1. Go to Firebase Console
  2. Create a new project (or select existing)
  3. Add Android app with package: site.stackverify.smsrelay
  4. Download google-services.json
  5. Place it in: app/google-services.json
  6. Enable Firebase Cloud Messaging in console

3. Build and Run

# Build the project
./gradlew build

# Run on emulator or device
./gradlew installDebug

4. Server API Integration

Update API endpoints in AppConstants.kt:

const val BASE_URL = "https://your-api.com/api/"

Required API Endpoints:

POST /auth/login

Request:

{
  "email": "user@example.com",
  "password": "password123",
  "appId": "APP_Manufacturer_Model_Timestamp",
  "fcmToken": "FCM_TOKEN_HERE"
}

Response:

{
  "success": true,
  "token": "JWT_TOKEN",
  "message": "Login successful",
  "userId": "USER_ID"
}

POST /device/register-fcm

Request:

{
  "fcmToken": "FCM_TOKEN"
}

Response:

{
  "success": true
}

POST /sms/status

Request:

{
  "smsId": "SMS_ID_FROM_FCM",
  "status": "sent|failed|pending",
  "timestamp": 1234567890
}

Response:

{
  "success": true,
  "message": "Status updated"
}

5. Firebase Cloud Messaging Data Format

Send FCM messages to topic all_devices with this structure:

{
  "data": {
    "action": "send_sms",
    "smsId": "UNIQUE_ID",
    "number": "+1234567890",
    "message": "Hello World"
  }
}

Or for notifications:

{
  "data": {
    "action": "notification",
    "title": "SMS Relay",
    "body": "Message forwarded successfully",
    "id": "NOTIFICATION_ID"
  }
}

Dependencies

  • Android Core: AndroidX, Material Design 3
  • Networking: Retrofit 2, OkHttp 3, Gson
  • Database: Room, Coroutines
  • Firebase: Cloud Messaging, Analytics, Crashlytics
  • Logging: Timber
  • Kotlin: Coroutines, Extensions

Security Features

  1. Token-based Authentication - JWT tokens saved securely
  2. HTTPS Only - No cleartext traffic in production
  3. App Signing - Google Play App Signing enabled
  4. ProGuard Obfuscation - Code protection enabled
  5. Encrypted Storage - SharedPreferences + EncryptedSharedPreferences
  6. Permission Management - Minimal permissions requested
  7. Crash Reporting - Firebase Crashlytics integration

Permissions

  • SEND_SMS - To send SMS messages
  • READ_PHONE_STATE - To detect phone state
  • INTERNET - Network communication
  • ACCESS_NETWORK_STATE - Network availability check
  • WAKE_LOCK - FCM background processing

Logging & Debugging

The app uses Timber for comprehensive logging:

Timber.d("Debug message")
Timber.e(exception, "Error message")
Timber.w("Warning message")

In production build, only errors are logged. Debug logs are suppressed.

Error Handling

The app handles:

  • Network failures gracefully
  • Invalid credentials
  • Missing permissions
  • Firebase connection issues
  • Database errors
  • SMS sending failures

All errors are logged and reported to crash analytics.

Testing

The app is structured for easy unit and integration testing:

  • Dependency injection ready
  • Repository pattern for data access
  • Separate concerns (auth, network, storage, SMS)

Production Checklist

  • Update API base URL
  • Configure Firebase project
  • Download google-services.json
  • Set up backend API endpoints
  • Enable Firebase Crashlytics
  • Configure analytics
  • Create signing key for Play Store
  • Set up ProGuard/R8
  • Test on real devices
  • Load test FCM delivery
  • Enable backup and restore
  • Test offline functionality

Performance Optimization

  • Efficient Database Queries - Indexed searches
  • Coroutine-based Async - Non-blocking operations
  • Lazy Loading - RecyclerView pagination ready
  • Memory Management - Proper lifecycle handling
  • Network Optimization - Connection pooling, timeout management

Troubleshooting

FCM Messages Not Received

  • Check Firebase Cloud Messaging is enabled
  • Verify app is subscribed to topic
  • Check internet connectivity
  • Review logcat for errors

SMS Not Sending

  • Verify SMS permission granted
  • Check phone has SMS capability
  • Verify recipient number format
  • Check device has cellular/active SIM

Login Fails

  • Verify API endpoint is correct
  • Check email/password credentials
  • Ensure network connectivity
  • Check Firebase token generation

App Crashes

  • Check logcat/Crashlytics reports
  • Verify all dependencies installed
  • Check for null pointer exceptions
  • Review error logs in Timber

Version History

  • v1.0.0 - Initial production release
    • Complete auth flow
    • SMS handling via FCM
    • SMS history tracking
    • Beautiful Material Design UI
    • Production-ready error handling

License

Proprietary - SMS Relay Service

Support

For support, contact: support@stackverify.site


Made with ❤️ for secure SMS relay service

About

stackedge sms relay gateway app that allows devs to send sms using their phones as sms gateway

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Kotlin 96.8%
  • Shell 3.2%