Skip to main content

How to use Diyalog IOS SDK

Diyalog SDK is used for enabling messaging for your application. It is a multi-platform communication Messaging SDK for mobile and web. It is easy to integrate, save development cost and delight users with a stable, secure and customization messaging.

SDK Supports#

Diyalog SDK supported with iOS 10.0 & Above

Integration Steps#

Step 1: Adding DiyalogEngine to your project

You need to add DiyalogEngine and their dependencies j2objc, webrtc and opus frameworks to your project.
DiyalogEngine framework and its dependencies started to be published as xcframework. You need to add it to your project as Xcframework.
The dependent j2objc should not be embedded in the application package. This framework is required for your application to be compiled with DiyalogEngine. Other WebRTC and opus frameworks must be embed.

You have 3 choices to add DiyalogEngine framework and dependency frameworks to your project.

  • Using Carthage

    Create or add your Cartfile with following lines of dependency definitions

    binary "https://diyalog.im/app/pkgs/ios_frameworks/DiyalogEngine.json" == version-no

    *version-no : You should be update with current stable version number.

    Other Dependencies :

    binary "https://diyalog.im/app/pkgs/ios_frameworks/WebRTC.json" == 1.1.2941
    binary "https://diyalog.im/app/pkgs/ios_frameworks/j2objc.json" == 1.0.3
    binary "https://diyalog.im/app/pkgs/ios_frameworks/opus.json" == 1.3

    then update carthage of your project by following command.

    carthage update --use-xcframeworks
  • Using CocoaPods

    The following dependencies need to be added to your PodFile file.

    pod 'DiyalogEngine', :git => 'https://github.com/diyalog-im/DiyalogEngine.git', :tag => '*version-no'
    pod 'j2objc', :git => 'https://github.com/diyalog-im/j2objc.git', :tag => '1.0.3'
    pod 'WebRTC', :git => 'https://github.com/diyalog-im/WebRTC.git', :tag => '1.1.2941'
    pod 'opus', :git => 'https://github.com/diyalog-im/opus.git', :tag => '1.3'

    *version-no : You should be update with current stable version number.

    In addition, please add following script to the end of your podfile after replacing Your-Target-Name with your project target name.

    post_install do |installer|
    installer.pods_project.targets.each do |target|
    if target.name == "Pods-**Your-Target-Name**"
    target.build_configurations.each do |config|
    xcconfig_path = config.base_configuration_reference.real_path
    xcconfig = File.read(xcconfig_path)
    xcconfig.sub!('-framework "j2objc"', '')
    File.open(xcconfig_path, "w") do |file|
    file << xcconfig
    end
    end
    end
    end
    end

    then run pod install command in your project.

    pod install

Step 2: Need to make required changes in Capabilities of the project as below:

Capabilities

And also background mode

Backgroundmodes

Step 3: In your Project, open AppDelegate.swift file and import DiyalogEngine framework. Add override init() method, Inside that method set below code.

import UIKit
import DiyalogEngine
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
override init(){
super.init();
DiyalogEngine.diyalogInstance().endpoints = ["wss://<YOUR_DIYALOG_SERVER>"]
//Diyalog Test App
DiyalogEngine.diyalogInstance().apiId = <YOUR_APP_API_ID>
DiyalogEngine.diyalogInstance().apiKey = "<YOUR_APP_API_KEY>"
DiyalogEngine.diyalogInstance().trustedKeys = [
"<YOUR_DIYALOG_ENVIRONMENT_PUBLIC_KEY_1>",
"<YOUR_DIYALOG_ENVIRONMENT_PUBLIC_KEY_2>",
"<YOUR_DIYALOG_ENVIRONMENT_PUBLIC_KEY_3>",
"<YOUR_DIYALOG_ENVIRONMENT_PUBLIC_KEY_4>",
"<YOUR_DIYALOG_ENVIRONMENT_PUBLIC_KEY_5>",
"<YOUR_DIYALOG_ENVIRONMENT_PUBLIC_KEY_6>"
]
DiyalogEngine.diyalogInstance().setappName("<YOUR_APP_NAME>")
DiyalogEngine.diyalogInstance().setLocalizationLanguage(.turkish)
DiyalogEngine.diyalogInstance().setenableCalls(true)
DiyalogEngine.diyalogInstance().setisSupportBackButton(true)
DiyalogEngine.diyalogInstance().createDiyalog()
}
}

Now you are ready to use Diyalog SDK in your application. You should read the next section about configuration parameters. Diyalog SDK gives you many customization in the chat views. You can learn details about styling Diyalog in styling document.