Integrating Popin SDK in Android

Integrating Popin SDK in Android

Introduction

This article explains how to integrate and use the PopinAndroidSDK library to add video calling functionality in your Android application. The SDK is easy to integrate and comes with pre-built classes like PopinConnectingDialog to handle video call connection states.

Step 1: Add PopinAndroidSDK Dependency

First, ensure that your project has the correct dependency for the PopinAndroidSDK.

  1. Open your project’s settings.gradle and add the JitPack repository to resolve the Popin library.

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
    }

Add the following dependency to your build.gradle file:

dependencies {
    implementation 'com.github.Springr-Creatives:PopinAndroidSDK:1.5.9'
}

Step 2: Initialize PopinAndroidSDK

Once the SDK is added, initialize the Popin service in your activity. This is typically done in the onCreate method of your main activity.

Popin.init(MainActivity.this);

This method prepares the SDK to handle video calls.

Step 3: Create a Call Button

Next, you can create a button in your layout XML file (e.g., activity_main.xml) to trigger a video call:

<Button
    android:id="@+id/buttonCall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Start Call"/>

Step 4: Implement Call Button Functionality

In your MainActivity.java, locate the Button and add an OnClickListener to initiate the call:

Button buttonCall = findViewById(R.id.buttonCall);
buttonCall.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        // Show "Connecting..." dialog
        PopinConnectingDialog cdd = new PopinConnectingDialog(MainActivity.this);
        cdd.show();

        // Start the video call and handle call events
        Popin.getInstance().startCall(new PopinEventsListener() {
            @Override
            public void onCallStart() {
                // The call has started
            }

            @Override
            public void onQueuePositionChanged(int i) {
                // Update UI based on queue position (if applicable)
            }

            @Override
            public void onAllExpertsBusy() {
                // Dismiss the dialog if all experts are busy
                cdd.dismiss();
            }

            @Override
            public void onCallConnected() {
                // Dismiss the dialog when the call connects
                cdd.dismiss();
            }

            @Override
            public void onCallFailed() {
                // Dismiss the dialog if the call fails
                cdd.dismiss();
            }

            @Override
            public void onCallDisconnected() {
                // Handle call disconnection logic here
            }
        });
    }
});

Explanation of Call Events:

  • onCallStart(): Triggered when the call starts connecting.
  • onQueuePositionChanged(int i): Provides updates if the call is in a queue.
  • onAllExpertsBusy(): Called when all call participants (experts) are busy.
  • onCallConnected(): Called when the call successfully connects.
  • onCallFailed(): Called when the call fails to connect.
  • onCallDisconnected(): Called when the call disconnects.

Step 5: PopinConnectingDialog

PopinConnectingDialog is a custom dialog that appears while the call is connecting. It shows a "Please Wait" message to the user. You can customize this dialog by editing the layout or message as needed.

PopinConnectingDialog cdd = new PopinConnectingDialog(MainActivity.this);
cdd.show();
This ensures the user has visual feedback while the call is being connected.

    • Related Articles

    • I am not receiving calls on my Android app. What do I do ?

      OPTIMIZING POPIN SELLER APP ON ANDROID PHONE 1. Issue Identification * Not receiving calls after installing Popin Seller app on Android phone. 2. Reason for Issue * Android manufacturers optimize usage and restrict permissions for newly installed ...
    • Integrating Popin Sales Tracking on Shopify

      To ensure seamless sales tracking with Popin, please follow the steps below to integrate the new Popin sales tracking pixel into your Shopify store. Steps to Integrate Popin Sales Tracking Step 1: Access Your Shopify Admin Panel Log in to your ...
    • Purpose of Popin: 1-1 Video Shopping Software

      1. Introduction to Popin: * Popin is a 1-1 video shopping software as a service. * It is used for consultative selling, product demos, and personalized customer interactions. 2. Customer Journey: * Problem: Customers may feel overwhelmed by product ...
    • How do I get started with the Popin Seller agent app?

      GUIDE TO USING THE POPIN APP AS AN AGENT 1. Download and Install the App * Search for ""popin seller"" in your app store (Android or iOS). * Download and install the app. 2. Login Process * Open the app and enter the number provided in the dashboard. ...
    • Understanding Common Media Errors in Popin

      When using Popin, a web application that leverages media devices like cameras and microphones, you may encounter various errors related to permissions, device availability, and secure contexts. This article aims to explain some common media-related ...