虎牙开放平台文档

hyExt.context.onShareLiveNotice

  • 监听分享直播间事件
  • 开播状态下才有分享回调,且伴随频率限制:
      1. 单个用户对单个主播每小时只能有1次
      1. 单个主播每分钟最多10次
  • 引入版本 1.7.0
  • 适用终端
    • 虎牙直播主站
    • 虎牙直播APP-iOS:7.13.353
    • 虎牙直播APP-安卓:7.13.6
    • 虎牙直播助手-iOS:4.7.6
    • 虎牙直播助手-安卓:4.7.6
    • 虎牙直播PC客户端-主播侧:4.18.4.0
    • 虎牙直播PC客户端-观众侧:未验证

接口签名

declare namespace hyExt { module context { /** * 监听分享直播间事件 * @param params 输入参数 */ function onShareLiveNotice(params: ShareLiveNoticeReq): Promise<void> } /** * 监听分享直播间参数 */ type ShareLiveNoticeReq = { /** * 分享直播间回调 */ callback: ShareLiveNoticeCallback } /** * 分享直播间回调 * @param notice 直播间分享消息 */ type ShareLiveNoticeCallback = (notice: ShareLiveNotice) => void /** * 直播间分享消息 */ type ShareLiveNotice = { /** * 直播间跳转链接 */ actionUrl: string /** * 分享内容 */ content: string /** * 分享图片的url */ imageUrl: string /** * 主播unionId */ presenterUnionId: string /** * 房间Id */ roomId: number /** * 分享类型,默认0 */ shareType: number /** * 分享人的昵称 */ sharerNick: string /** * 分享人的unionId */ sharerUnionId: string /** * 直播间副标题 */ subtitle: string /** * 直播间标题 */ title: string } }

示例代码

hyExt.context .onShareLiveNotice({ callback: (notice) => { const { actionUrl, content, imageUrl, presenterUnionId, roomId, shareType, sharerNick, sharerUnionId, subtitle, title, } = notice console.log("回调触发", notice) }, }) .then(() => { console.log("调用hyExt.context.onShareLiveNotice成功") }) .catch((err) => { console.log("调用hyExt.context.onShareLiveNotice失败", err) })

相关链接