Android QuickStart Guide

In this part you will learn how to setup SDK in android platform step by step. By doing these steps you will be able to make an internet call between 2 android devices.

Note

For more information look at REST API and Android SDK documents.

0. Prerequisites

  • Firebase Account
  • HyperRTC Account
  • Node.js & NPM ( version 8 or later )
  • 2 Android Devices (‌ or simulators )

1. Creating an application in HyperRTC

At first, you need to create an application. Look at Applications>Create in Kavenegar panel. Then save the given API-Token for the next steps.

2. Creating a Firebase Project

At HyperRTC internet calling service, push notification service notifies the received calls to the receptor.

It means that, when the caller decides to make a call with receptor, the call request is sent to the receptor by push notification.

There are variety of services for sending push notifications to android, that we use Firebase in this guide.

Note

In case you use another service for sending push notifications, you can use this section in that service.

To set up, look at Firebase Console and follow the steps in this video:

  • Make a project

  • Then make an android application with the following package name : io.kavenegar.call.android.sample

  • Save the google-services.json file and skip the other steps.

  • Go to page Setting > Service accounts and click Generate a new private key button on Firebase Admin SDK tab and save the file.

Note

In case of doing the steps that mentioned in the video in the right way, you must have received 2 files:

  • ‍‍google-services.json file that would be used in android sample code.
  • FireBase Admin SDK file that would be used for sending push notification in Back-End sample project.

3. Running Back-End Sample Project

To implement internet calling service, something should be applied in Back-End:

  • Making call by HyperRTC REST API
  • Sending push notification
  • Detection of user identities

To set up Back-End sample code follow these steps:

  • Receive the sample code from the following route :
https://github.com/kavenegar/call-backend-sample-node
  • Transfer the Firebase Admin SDK file that you received from previous step, to the main branch of Back-End project.

  • To perform the project (without sending push notification to iOS feature) you need to initialize the following parameters:

    • backend:kavenegar-api-token : kavenegar application ID (Application Token) that you received right after making application.
    • backend:firebase-project-file : file Firebase Admin SDK route that received from previous step.

To setup, follow this command:

npm install && npm start -s --backend:kavenegar-api-token=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJpbmZvQG1vaHNlbi53b3JrIiwicm9sZXMiOiJ1c2VyIiwidXNlcklkIjoxLCJhcHBsaWNhdGlvbklkIjoxLCJpYXQiOjE1MjU1MDExNzd9.N7B7kB3ATFKYcUgVkpybKM5dMmSUlIDiycUMHd2_sLY --backend:firebase-project-file=./kavenegar-call-test-firebase-adminsdk-3c13i-5854914aaf.json

Then you will receive this output:

Kavenegar Backend Sample Config :  {
    "kavenegarApiToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJpbmZvQG1vaHNlbi53b3JrIiwicm9sZXMiOiJ1c2VyIiwidXNlcklkIjoxLCJhcHBsaWNhdGlvbklkIjoxLCJpYXQiOjE1MjU1MDExNzd9.N7B7kB3ATFKYcUgVkpybKM5dMmSUlIDiycUMHd2_sLY",
    "firebaseProjectFile": "./kavenegar-call-test-firebase-adminsdk-3c13i-5854914aaf.json"
}
Kavenegar Backend Sample is listening on port 3000
[http://192.168.1.189:3000]

If you receive similar message, it means that setting was successful and do the next step. 👌

Note

At the mentioned output, the 192.168.1.189 address is general and for connecting android application to Back-End, you need to use this IP.

4. Running Android Sample Project

  • You can download the android sample project from the following address:

    https://github.com/kavenegar/call-android-sample
    
  • After downloading the project, open it with Android Studio, version 3 or later.

  • Open the file MyApplication.java and insert the Back-End public address that you received from the previous step.

    public class MyApplication extends Application {
    
        static final String BACKEND_URL = "http://192.168.1.189:3000"; // [1]
    
        @Override
        public void onCreate() {
            KavenegarCall.initialize(this, Environment.PRODUCTION);
            super.onCreate();
        }
    }
    
    
  • Then move the google-services.json file you have downloaded from the second step, to sample directory in project.

    Copy google-services file to application root

  • Finally create the application and run it on two devices.

5. Testing

After completing all the following steps you can make an internet call between two android devices.

To do this, install the Android app on two devices or simulators. For example, on the first device login with the username Mohsen and on the second device with the username Mohammad. If both of them have successfully logged in, type the other username in one of the devices and click the call button.

Android App Preview


Android SDK Documentation → REST API Documentation →