Commit 618097b5 authored by DavidHuang's avatar DavidHuang

使用短链分享

parent 6334cf05
...@@ -433,39 +433,25 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -433,39 +433,25 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
return return
} }
// //直播 分享连接
// 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 { DispatchQueue.global().async {
if let url = YHShareManager.shared.createMutilShareUrl(type: 1, param: ["LiveID":String(self.liveId)]) { YHShareManager.shared.createMutilShareShortUrl(type: 1, param: ["LiveID":String(self.liveId)]) { shortUrl, error in
let tmpT = url.base64Encoded ?? ""//对deepLink使用 base64编码 if let url = shortUrl {
var oldUrl = liveModel.live_h5_url let tmpT = url.base64Encoded ?? ""//对deepLink使用 base64编码
if oldUrl.contains("?") { var oldUrl = liveModel.live_h5_url
oldUrl = oldUrl + "&uid=\(YHLoginManager.shared.userModel?.id ?? "0")" + "&fromPlatform=iOS" + "&appDeepLink=\(tmpT)" if oldUrl.contains("?") {
} else { oldUrl = oldUrl + "&appDeepLink=\(tmpT)"
oldUrl = oldUrl + "?uid=\(YHLoginManager.shared.userModel?.id ?? "0")" + "&fromPlatform=iOS" + "&appDeepLink=\(tmpT)" } else {
oldUrl = oldUrl + "?appDeepLink=\(tmpT)"
}
DispatchQueue.main.async {
YHShareAlertView.show(image: liveModel.live_image, title: "@" + liveModel.account, subMessage: liveModel.live_title, linkUrl: oldUrl, isLive: true, fromAiSale: true)
}
return
} }
DispatchQueue.main.async { DispatchQueue.main.async {
YHShareAlertView.show(image: liveModel.live_image, title: "@" + liveModel.account, subMessage: liveModel.live_title, linkUrl: oldUrl, isLive: true, fromAiSale: true) YHShareAlertView.show(image: liveModel.live_image, title: "@" + liveModel.account, subMessage: liveModel.live_title, linkUrl: liveModel.live_h5_url, isLive: true, fromAiSale: true)
} }
return
}
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)
} }
} }
} }
......
...@@ -279,7 +279,6 @@ extension YHShareManager { ...@@ -279,7 +279,6 @@ extension YHShareManager {
return nil return nil
} }
//直播 分享连接 //直播 分享连接
let components = AGCAppLinkingComponents() let components = AGCAppLinkingComponents()
...@@ -294,10 +293,8 @@ extension YHShareManager { ...@@ -294,10 +293,8 @@ extension YHShareManager {
if let value = param[item],!value.isEmpty { if let value = param[item],!value.isEmpty {
linkUrl = linkUrl + "&" + item + "=" + value linkUrl = linkUrl + "&" + item + "=" + value
} }
} }
components.deepLink = linkUrl components.deepLink = linkUrl
components.iosBundleId = Bundle.main.bundleIdentifier components.iosBundleId = Bundle.main.bundleIdentifier
components.androidDeepLink = linkUrl //安卓平台调用不过 所以需要单独写出来 components.androidDeepLink = linkUrl //安卓平台调用不过 所以需要单独写出来
...@@ -306,4 +303,36 @@ extension YHShareManager { ...@@ -306,4 +303,36 @@ extension YHShareManager {
let url = components.buildLongLink() let url = components.buildLongLink()
return url.absoluteString return url.absoluteString
} }
func createMutilShareShortUrl(type: Int,param : [String : String],callBack: @escaping ((String?,Error?) -> Void)) {
if type < 1 {
callBack(nil,nil)
return
}
//直播 分享连接
let components = AGCAppLinkingComponents()
//通过urlPrefix属性设置为申请链接前缀中的链接前缀
components.uriPrefix = YhConstant.DeepLink.urlPreUrlFix
//通过deepLink属性设置深度链接地址
var linkUrl = YhConstant.DeepLink.url + "?" + "type=\(type)"
let arrKey = param.keys
for (_,item) in arrKey.enumerated() {
if let value = param[item],!value.isEmpty {
linkUrl = linkUrl + "&" + item + "=" + value
}
}
components.deepLink = linkUrl
components.iosBundleId = Bundle.main.bundleIdentifier
components.androidDeepLink = linkUrl //安卓平台调用不过 所以需要单独写出来
components.androidPackageName = "com.galaxy.galaxyandroid"
components.buildShortLink { shortLink, error in
callBack(shortLink?.url.absoluteString, error)
}
}
} }
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