Skip to content

platfone-com/temp-number-android

Repository files navigation

Sample Android App for Temp Number Backend

This is a sample Android app designed for developers to demonstrate the main flows and integration with the Temp-Number Backend. The app allows users to purchase virtual mobile numbers to receive SMS messages online, SMS activation, OTP verification, and SMS Activate workflows. The Temp-Number Backend is a ready-to-use open-source backend, providing all necessary functionality for seamless app integration and SMS management.

Sample App Screenshots:

Screen 1 Screen 2 Screen 3 Screen 4
Screen 5 Screen 6 Screen 7 Screen 8

Main Features

  1. Primary App Features:

    • User Authentication: Supports Firebase Authentication (Google Sign-In, Email, etc.).
    • Service and Country Pricing: Displays pricing for selected services and countries.
    • Temporary Number Ordering: Users can order numbers and manage active/expired numbers.
    • SMS Handling: Receives and displays SMS messages.
    • Report Issues: Users can submit and track reports.
    • Payments: Supports Google Play and Stripe for account balance top-ups.
    • Transaction History: Provides a record of financial transactions.
  2. Backend

  3. Payments (Google Play & Stripe)

    • Google Play In-App purchases and Stripe are integrated for secure balance top-ups, with backend handling verification for purchases and refunds.

Getting Started

Watch the guide on YouTube

Demo video

Follow these steps to set up the project on your local machine.

Prerequisites

Step 1: Clone the Repository

Clone this repository to your local machine.

Step 2: Configure Firebase Project

This project requires Firebase for authentication. Both Temp Number Backend and this Android app will use the same Firebase project.

You should already have a Firebase project if you followed the Temp Number Backend setup. If not, please install Temp Number Backend first.

Add Android App to Firebase project:

  • Follow the Firebase setup documentation to add an Android app to your project.
  • Use a unique applicationId (e.g., com.yourcompany.yourapp). You will use this in Step 4.
  • Download the google-services.json file. You will add this to the project in Step 4.
  • If using Google Sign-In, add your SHA-1 fingerprint in Project Settings > General > Your apps > Android.

Step 3: Configure the Android App

Now, configure the cloned Android app to connect to your services.

  1. Change applicationId:

    • Open app/build.gradle and change the applicationId to match the one you registered in Firebase.

      defaultConfig {
          applicationId "com.yourcompany.yourapp"  // Replace with your own
      }
  2. Add google-services.json:

    • Place the google-services.json file you downloaded from Firebase (Step 2.3) into the app/ directory of this project.
  3. Set API Endpoint:

    • Open the ApiClient class and locate the API_ENDPOINT constant.
    • Set this value to point to your backend API endpoint.

Choose one of:

Environment Device Endpoint value Description
Local backend Android Emulator LOCAL_EMULATOR_API_ENDPOINT Uses http://10.0.2.2:<PORT> to access your computer’s localhost.
Local backend Real Android device (USB) LOCAL_REAL_DEVICE_ENDPOINT Uses http://localhost:<PORT> with adb reverse tcp:<PORT> tcp:<PORT>.
Cloud backend Any Your cloud backend URL, e.g. https://your-cloud-api-url/api/ Must match VITE_TEMP_NUMBER_BACKEND_API_BASE_PATH in web.env or installer output.

At this stage, the application should run and authenticate correctly. The following steps configure payments.

💡 Note: You can top-up customer accounts directly from the Platfone Retailer Dashboard without configuring payments in the app.

Step 5: Configure Payments

The app supports both Google Play in-app purchases and Stripe. At least one method should be configured for users to add funds.

Stripe Payments (Optional)

Configure Stripe by following the Temp Number Stripe setup guide

Google Play Payments (Optional)

This step is required if you plan to use in-app purchases.

  1. Configure Google Play in-app purchases by following the Temp Number Backend GP setup guide

  2. Sync In-App Purchase IDs:

    • You can use the default product IDs from the sample app (listed below) or configure your own in the Google Play Console.
    • Edit the constants in BillingConstants.kt to match the exact product IDs you set up.

    ⚠️ Important: The product IDs and their amounts in BillingConstants.kt must perfectly match the IDs and prices configured in the Temp-Number Backend settings. Any mismatch will cause payments to fail.

    Default constants in BillingConstants.kt to update:

    • one_dollar_purchase
    • five_dollar_purchase
    • twenty_five_dollar_purchase
    • fifty_dollar_purchase
  3. Testing Payments:

    • Once the products are configured and your app is published for testing, you can initiate payments from the app.

Step 6: Re-deploy Backend

After configuring payment providers (Stripe, Google Play) in the backend's settings, you must re-deploy your backend for the changes to take effect.

Step 7: Build and Run the Project

You are all set! Build and run the project in Android Studio.

Step 8: Switch to Production

Once you have tested the app and are ready to go live, ensure you switch from test credentials to production keys.

  1. Update Credentials: Replace all test credentials (e.g., Stripe Sandbox keys, Platfone API endpoint) with your Live / Production keys in the backend.secrets, backend.env, and web.env files of your backend.
  2. Final Re-deploy: Re-deploy the backend one last time to apply the production configuration.

License

This project is licensed under the MIT License with an API Restriction Clause. You may use it for personal or commercial projects with the Temp-Number Retail API. See the LICENSE file for details.

About

Temp Number Android example app

Resources

License

Stars

Watchers

Forks

Contributors