SwiftUI is a user interface toolkit, created by Apple, that helps you to build stunning apps across all Apple devices. QuickBlox iOS SDK is a ready-to-use software development kit that enables you to integrate chat and video calling functionality into any app. The QuickBlox SDK comes with detailed documentation and chat and video code samples, so that you can add real-time communication features easily to your app. The following tutorial explains how you can connect the QuickBlox iOS SDK to your latest SwiftUI project.
Learn more about, The iOS Chat Sample from QuickBlox
To get started with the QuickBlox IOS SDK, you first need to Login on the homepage of the QuickBlox dashboard. If you don’t yet have an account, sign-up for a free account now.
Check out our Quick Start documentation for more details.
You’ll use Xcode 14 to develop and test the app.
For installation of the QuickBlox SDK please follow instructions as detailed in our official documentation.
Please note that CocoaPods first needs to be installed.
Once you’ve installed the iOS SDK, open your project in Xcode by double clicking on the generated CocoaPods file YourProjectNameChat.xcworkspace
Make the AppDelegate available in your SwiftUI app.
Create a Swift file named AppDelegate which is part of the YourProjectNameChat target.
import UIKit import Quickblox import SwiftUI struct CredentialsConstant { static let applicationID:UInt = 12345 static let authKey = "YourAuthKey" static let authSecret = "YourAuthSecret" static let accountKey = "YourAccountKey" } class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { // Set QuickBlox credentials (You must create application in admin.quickblox.com). QBSettings.applicationID = CredentialsConstant.applicationID QBSettings.authKey = CredentialsConstant.authKey QBSettings.authSecret = CredentialsConstant.authSecret QBSettings.accountKey = CredentialsConstant.accountKey // enabling carbons for chat QBSettings.carbonsEnabled = true // Enables Quickblox REST API calls debug console output. QBSettings.logLevel = .debug // Enables detailed XMPP logging in console output. QBSettings.enableXMPPLogging() QBSettings.disableFileLogging() QBSettings.autoReconnectEnabled = true return true } }
In order to connect the AppDelegate to the project, you need to set up the Swift YourProjectNameChat.app file.
Open the Swift file YourProjectNameChatApp and add the Quickblox import to the top of the file.
Change the body of this class as shown below.
import SwiftUI import Quickblox @main struct YourProjectNameChatApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate var body: some Scene { WindowGroup { ContentView() } } }
You’ve successfully connected the QuickBlox iOS SDK to your SwiftUI project. You can now integrate chat and video calling functionality to your app. Read our detailed iOS documentation to learn more.
Learn more about: How to Launch iOS Chat and WebRTC Video conferencing samples
Learn more about: How to Build a Messaging App for iOS and Android with Meteor / Cordova