Integrating Popin SDK in iOS
Integrating Popin SDK in iOS
On this page
Introduction
Step 1: Add Popin iOS SDK Dependency
Step 2: Initialize Popin SDK
Step 3: Create a Call Button
Step 4: Implement Call Button Functionality
Step 5: PopinConnectingViewController
Introduction
This guide explains how to integrate the Popin iOS SDK into your iOS application to enable video calling functionality.
The SDK is designed for straightforward integration and provides pre-built components such as PopinConnectingViewController, which handles call connection states and provides real-time feedback to users during the call lifecycle.
Step 1: Add Popin iOS SDK Dependency
The Popin iOS SDK can be added to your project using Swift Package Manager (SPM).
Using Swift Package Manager
Open your project in Xcode.
Navigate to File → Add Packages…
Enter the Popin SDK repository URL:
Select the latest stable version.
Add the package to your app target.
Once added, the Popin SDK will be available throughout your project.
Step 2: Initialize Popin SDK
Initialize the Popin SDK when your application launches.
A token is required to authenticate and authorize SDK usage.
AppDelegate (UIKit lifecycle)
SceneDelegate (iOS 13+)
Note: The token should be securely retrieved from your backend or configuration system and should not be hardcoded in production builds.
Step 3: Create a Call Button
Add a button to your view controller that users can tap to start a video call.
Using Storyboard
Drag a UIButton onto your view.
Set the button title to “Start Call”.
Create an
@IBOutletand@IBActionconnection.
Using Programmatic UI (Swift)
Step 4: Implement Call Button Functionality
When the user taps the call button, display a connecting screen and initiate the video call.
Example: ViewController.swift
ViewController.swiftExplanation of Call Events
onCallStart
Triggered when the SDK begins connecting the call.
onQueuePositionChanged(Int)
Provides queue position updates if the user is waiting.
onAllExpertsBusy
Called when no agents or experts are available.
onCallConnected
Fired when the video call successfully connects.
onCallFailed
Called when the call cannot be established.
onCallDisconnected
Triggered when the call ends or is disconnected.
Step 5: PopinConnectingViewController
PopinConnectingViewController is a pre-built UI component that informs users that the call is being connected. It typically displays a “Connecting…” or “Please wait” message.
Showing the Connecting Screen
You may customize this screen by subclassing PopinConnectingViewController or adjusting its UI configuration options to match your application’s branding.
Last updated