Commit b6caaf6e authored by DavidHuang's avatar DavidHuang

1、生成直播链接

2、直播链接跳转直播间
parent 79157be7
......@@ -69,8 +69,40 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
AGCInstance.startUp()
AGCAppLinking.instance().handle { (link, error) in
let deepLink = link?.deepLink
//TODO: 增加deeplink地址跳转
if let deepLink = link?.deepLink,deepLink.contains(YhConstant.DeepLink.compareUrl) {
if let url = URL(string: deepLink) {
let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
if let queryItems = components?.queryItems {
var arrItems : [String : Any] = [:]
for item in queryItems {
if let value = item.value {
arrItems.updateValue(value, forKey: item.name)
}
}
if arrItems.count > 0 {
if let type = arrItems["type"] as? String,let iType = Int(type) {
if iType == 1 {
//跳转
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
if !YHLoginManager.shared.isLogin() {
printLog("需要登录")
return
}
//直播 - 获取它对应的参数
if let liveId = arrItems["LiveID"] as? String {
let playbackInfo = YHPlayerManager.PlaybackInfo(id: liveId.intValue(), isLive: true, isFromSaleDetail: true)
YHPlayerManager.shared.enterLive(from: nil, playbackInfo: playbackInfo)
}
}
} else {
}
}
}
}
}
}
}
// QiYu SDK初始化
......
......@@ -8,8 +8,8 @@
import AgoraRtcKit
import HyphenateChat
//import AVKit
import UIKit
import AGConnectAppLinking
class YHLivePlayerViewController: YHBasePlayerViewController {
// MARK: - Properties
......@@ -416,7 +416,32 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
guard let liveModel = viewModel.liveDetailModel else {
return
}
YHShareAlertView.show(image: liveModel.live_image, title: "@" + liveModel.account, subMessage: liveModel.live_title, linkUrl: liveModel.live_h5_url, isLive: true, fromAiSale: true)
// //直播 分享连接
// let components = AGCAppLinkingComponents()
// //通过urlPrefix属性设置为申请链接前缀中的链接前缀
// components.uriPrefix = "https://yinheapp.drcn.agconnect.link"
// //通过deepLink属性设置深度链接地址
// components.deepLink = "yinheapp://hkdiy-h5.galaxy-immi.com/galaxyapp?type=1&liveId=106"
// components.iosBundleId = Bundle.main.bundleIdentifier
// components.androidDeepLink = "yinheapp://hkdiy-h5.galaxy-immi.com/galaxyapp?type=1&liveId=106"
// components.androidPackageName = "com.galaxy.galaxyandroid"
// let url = components.buildLongLink()
DispatchQueue.global().async {
if let url = YHShareManager.shared.createMutilShareUrl(type: 1, param: ["LiveID":"106"]) {
printLog(url) //for test hjl
}
// printLog(url.absoluteString)
DispatchQueue.main.async {
YHShareAlertView.show(image: liveModel.live_image, title: "@" + liveModel.account, subMessage: liveModel.live_title, linkUrl: liveModel.live_h5_url, isLive: true, fromAiSale: true)
}
}
}
private func showGoods() {
......
......@@ -16,7 +16,7 @@ class YHLiveDetailModel: SmartCodable {
var hxUid: String = ""
var access_num: String = ""
var tips: String = ""
// 1:直播中 2:未直播 0:未知状态 3:结束直播
// 0:未知状态 1:直播中 2:未直播 3:结束直播
var status: Int = 0
// 1:正常 2:播放中 3:禁推---(当status==1才监测,3代表离开了)
var stream_status: Int = 0
......
......@@ -8,6 +8,7 @@
import UIKit
import Alamofire
import AGConnectAppLinking
class YHShareManager: NSObject {
static let shared = YHShareManager()
......@@ -267,4 +268,42 @@ extension YHShareManager {
WXApi.send(miniProgram)
}
/*
生成多平台分享链接,完成回环操作
type : 业务类型 1-直播
param : 业务对应的参数
*/
func createMutilShareUrl(type: Int,param : [String : String]) -> String? {
if type < 1 {
return nil
}
//直播 分享连接
let components = AGCAppLinkingComponents()
//通过urlPrefix属性设置为申请链接前缀中的链接前缀
components.uriPrefix = "https://yinheapp.drcn.agconnect.link"
//通过deepLink属性设置深度链接地址
var linkUrl = YhConstant.DeepLink.url + "?" + "type=\(type)"
let arrKey = param.keys
for (index,item) in arrKey.enumerated() {
if let value = param[item],!value.isEmpty,let value2 = YHURLEncodeHelper.urlEncodedString(value) {
linkUrl = linkUrl + "&" + item + "=" + value2
}
}
components.deepLink = linkUrl
components.iosBundleId = Bundle.main.bundleIdentifier
components.androidDeepLink = linkUrl//安卓平台调用不过 所以需要单独写出来
components.androidPackageName = "com.galaxy.galaxyandroid"
let url = components.buildLongLink()
return url.absoluteString
}
}
......@@ -237,6 +237,14 @@ class YhConstant {
extension YhConstant {
//DeepLink 常量
struct DeepLink {
static let url = "yinheapp://hkdiy-h5.galaxy-immi.com/galaxyapp"
static let compareUrl = "yinheapp://hkdiy-h5.galaxy-immi.com/galaxyapp?type="
}
// MARK: - 环信IM
struct IM {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment