QiscusStreaming 0.1.5

QiscusStreaming 0.1.5

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最新发布2018年3月
SPM支持 SPM

Ashari JuangAhmad Athaullah 维护。



 
依赖
LFLiveKit= 2.6
Alamofire= 4.5.1
SwiftyJSON= 3.1.4
 

  • ashari juang

Qiscus Streaming SDK IOS

Platform
Language
CocoaPods

Qiscus Streaming SDK 是一个让将语音通话和/或即时消息添加到移动应用变得容易的产品。它处理所有信令和音频管理的复杂性,同时为您创建出色的用户界面提供自由。

快速入门

以下是一步一步的指南,介绍如何首次设置 Qiscus Streaming SDK

安装

CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

def import_pods
    pod 'QiscusStreaming'
end

target 'Your Target'  do
    platform :ios, '8.0'
    import_pods
end

权限

添加到您的项目 Info.plist 中

<key>NSCameraUsageDescription</key>
<string>..</string>
<key>NSMicrophoneUsageDescription</key>
<string>..</string>

身份验证

使用您的 API 密钥初始化

在您的应用程序类中使用您的 API 密钥初始化 Qiscus

QiscusStreaming(withConfig: config)

参数

  • config: StreamConfig
import QiscusStreaming

let config      = StreamConfig()
config.AppId    = "Your_app_id"
client = QiscusStreaming(withConfig: config)

上面的示例 API 密钥具有有限的功能。要获取具有完整功能的 API 密钥,请联系我们

创建流

在用户可以开始相互流式传输之前,他们必须创建流链接

QiscusStreaming.createStream(title: String, tags: [String], completion: @escaping (Stream?) -> Void)

参数

  • title : String
  • tags : [String]
  • completion: @Escaping (String) -> Void
let config      = StreamConfig()
config.AppId    = "Your_app_id"
client = QiscusStreaming(withConfig: config)

client?.createStream(title: "streaming", tags: ["test"]) { (stream) in
    print("stream url : \(stream?.streamUrl)")
}

Stream 对象

  • streamUrl: String
  • watchUrl: String

开始流

开始视频流

let config      = StreamConfig()
config.AppId    = "Your_app_id"
client = QiscusStreaming(withConfig: config)

client?.buildStream(streamUrl: url!, completionHandler: { (target, error) in
    self.present(target, animated: true, completion: nil)
})

您可以从流对象中获取 stream_url。

实现

import QiscusStreaming

var client : QiscusStreaming?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        buttonStream.addTarget(self, action: #selector(self.tapSample(_:)), for: UIControlEvents.touchUpInside)
        buttonLive.addTarget(self, action: #selector(self.goStream(_:)), for: UIControlEvents.touchUpInside)
        let config      = StreamConfig()
        config.AppId    = "a3d2QkJXQ2M1YTdrTW1PYnVJSmJiUVczTkxmS3BRc05nYnRCOHRGUw=="
        client = QiscusStreaming(withConfig: config)
    }

    func tapSample(_ sender: Any) {
        client?.createStream(title: "streaming", tags: ["test"]) { (stream) in
            print("stream url : \(stream?.streamUrl)")
            self.urlTextField.text = stream?.streamUrl
        }
    }
    
    func goStream(_ sender: Any) {
        //
        let url = self.urlTextField.text
        client?.buildStream(streamUrl: url!, completionHandler: { (target, error) in
            //
            self.present(target, animated: true, completion: nil)
        })
    }

您可以使用 VLC(https://www.videolan.org/vlc/)测试实时流。
打开 Vlc,文件,打开网络,在调用 QiscusStream.createStream 方法后输入流 URL。



示例

  • (基本示例)
  • (Qiscus Chat SDK 集成)