iOS UI Kit — Implementation
Once installation is complete and you have a valid token, launching the full video UI takes
only a few lines of Swift or Objective-C. EnxVideoViewClass is a subclass of
UIView — simply add it to your view hierarchy and the kit manages all media
negotiation, controls, and layout internally.
- Valid room token obtained from your application server
- Camera and microphone runtime permissions granted (see Installation → Permissions)
Add the import statement at the top of the file where you present the video session.
import Enx_UIKit_iOS
@import Enx_UIKit_iOS;
@class Enx_UIKit_iOS;
@interface YourViewController : UIViewController
// your interface declarations
@end
EnxVideoViewClass takes three arguments:
- token — the room token from your app server
- delegate — a reference to the object that implements the callback protocol (typically
self) - embedUrl — an optional Low Code embed URL for importing UI settings from the EnableX Visual Builder; pass
nil/ empty string if unused
After creating the view, add it to your view hierarchy and pin it to fill the screen.
Setting autoresizingMask ensures the kit handles device rotation correctly.
let enxViewer = EnxVideoViewClass(
token: "YOUR_ROOM_TOKEN",
delegate: self,
embedUrl: "LOW_CODE_EMBED_URL" // pass nil or "" if unused
)
view.addSubview(enxViewer)
enxViewer.frame = self.view.bounds
enxViewer.autoresizingMask = [.flexibleWidth, .flexibleHeight]
EnxVideoViewClass *videoView = [[EnxVideoViewClass alloc]
initWithToken:@"YOUR_ROOM_TOKEN"
delegate:self
embedUrl:@"LOW_CODE_EMBED_URL"];
[self.view addSubview:videoView];
videoView.frame = self.view.bounds;
videoView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
EnxVideoViewClass manages all media negotiation, participant tiles, controls,
and layout internally. You do not need to build or manage any video UI yourself. Set
autoresizingMask to ensure it adapts correctly on device rotation.
Implement the delegate protocol in your view controller to respond to session lifecycle events. At minimum you should handle disconnection and connection errors so your app can navigate correctly after the session ends.
Disconnection Callback
Called when the local participant leaves the room, whether initiated by the user, the moderator, or a network error. Use this to dismiss the video view and navigate back to your app's main flow.
func disconnect(response: [Any]?) {
// response contains the disconnect reason
// Clean up, dismiss the view, and navigate home
DispatchQueue.main.async {
self.navigationController?.popViewController(animated: true)
}
}
Connection Error Callback
Called when the kit cannot establish a connection to the EnableX room. The
reason array contains a description of the error — display it to the user or log
it for debugging.
func connectError(reason: [Any]?) {
// reason contains error details
// Show an alert or navigate away
print("Connection error: \(reason ?? [])")
}
Screen Share Callbacks
If you enable screen sharing via a ReplayKit broadcast extension, the kit delivers these additional lifecycle events:
| Callback | When it fires |
|---|---|
broadCast(connected date: [Any]?) |
Broadcast extension connected and streaming has started |
failedToConnect(withBroadCast reason: [Any]?) |
Broadcast extension failed to connect |
broadCastDisconnected() |
Broadcast extension disconnected normally |
disconnectedByOwner() |
The session owner disconnected the broadcast |
requestedTo(exitRoom: [Any]?) |
A moderator has requested that this participant exit the room |