Showing
2 changed files
with
255 additions
and
27 deletions
| @@ -7,26 +7,26 @@ | @@ -7,26 +7,26 @@ | ||
| 7 | </p> | 7 | </p> |
| 8 | 8 | ||
| 9 | * [HHDoctorSDK 接入说明](#hhdoctorsdk-接入说明) | 9 | * [HHDoctorSDK 接入说明](#hhdoctorsdk-接入说明) |
| 10 | - * [1. 概要介绍](#1-概要介绍) | ||
| 11 | - * [2. 集成方式](#2-集成方式) | ||
| 12 | - * [2.1. 手动集成](#21-手动集成) | ||
| 13 | - * [2.2. 自动集成](#22-自动集成) | ||
| 14 | - * [2.3. 调用规则](#23-调用规则) | ||
| 15 | - * [3. 初始化](#3-初始化) | ||
| 16 | - * [4. 登录账户](#4-登录账户) | ||
| 17 | - * [4.1. 登录](#41-登录) | ||
| 18 | - * [4.2. 登出](#42-登出) | ||
| 19 | - * [5. 视频呼叫](#5-视频呼叫) | ||
| 20 | - * [6. 代理(delegate)(可选)](#6-代理delegate可选) | ||
| 21 | - * [6.1. 加入](#61-加入) | ||
| 22 | - * [6.2. 移除](#62-移除) | 10 | + * [1. 集成方式](#1-集成方式) |
| 11 | + * [1.1. 手动集成](#11-手动集成) | ||
| 12 | + * [1.2. 自动集成](#12-自动集成) | ||
| 13 | + * [1.3. 调用规则](#13-调用规则) | ||
| 14 | + * [2. 初始化](#2-初始化) | ||
| 15 | + * [3. 登录账户](#3-登录账户) | ||
| 16 | + * [3.1. 登录](#31-登录) | ||
| 17 | + * [3.2. 登出](#32-登出) | ||
| 18 | + * [4. 视频呼叫](#4-视频呼叫) | ||
| 19 | + * [5. 代理(delegate)(可选)](#5-代理delegate可选) | ||
| 20 | + * [5.1. 加入](#51-加入) | ||
| 21 | + * [5.2. 移除](#52-移除) | ||
| 23 | 22 | ||
| 24 | -## 1.概要介绍 | ||
| 25 | -## 2.集成方式 | 23 | + |
| 24 | +## 1. 集成方式 | ||
| 26 | HHDoctorSDK 提供两种集成方式:您既可以通过 CocoaPods 自动集成我们的 SDK,也可以通过手动下载 SDK, 然后添加到您的项目中。 | 25 | HHDoctorSDK 提供两种集成方式:您既可以通过 CocoaPods 自动集成我们的 SDK,也可以通过手动下载 SDK, 然后添加到您的项目中。 |
| 27 | 我们提供的下载地址: | 26 | 我们提供的下载地址: |
| 28 | 27 | ||
| 29 | - 我们提供了发布仓库 [HHDoctorSDK](https://code.hh-medic.com/hh_public/HHDoctorSDK.ios)。 | 28 | + 我们提供了发布仓库: [HHDoctorSDK](https://code.hh-medic.com/hh_public/HHDoctorSDK.ios)。 |
| 29 | + 集成demo地址: [HHDoctorSDK_demo_iOS](https://github.com/HHMedic/HHDoctorSDK_demo_iOS) | ||
| 30 | 30 | ||
| 31 | 由于呼叫视频需要相机相册权限,需要在info.plist中添加对应的权限,否则会导致无法调用。 | 31 | 由于呼叫视频需要相机相册权限,需要在info.plist中添加对应的权限,否则会导致无法调用。 |
| 32 | 32 | ||
| @@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
| 39 | <string>应用需使用麦克风权限,以便您向医生进行视频咨询。</string> | 39 | <string>应用需使用麦克风权限,以便您向医生进行视频咨询。</string> |
| 40 | ``` | 40 | ``` |
| 41 | 41 | ||
| 42 | -### 2.1.手动集成 | 42 | +### 1.1. 手动集成 |
| 43 | 43 | ||
| 44 | 1. 根据自己工程需要,下载对应版本的 HHMSDK,得到 NIMSDK.framework ,NIMAVChat.framework,NVS.framework,SecurityKit.framework 和 HHDoctorSDK.framework,以及未链接的全部三方依赖库 ,将他们导入工程。 | 44 | 1. 根据自己工程需要,下载对应版本的 HHMSDK,得到 NIMSDK.framework ,NIMAVChat.framework,NVS.framework,SecurityKit.framework 和 HHDoctorSDK.framework,以及未链接的全部三方依赖库 ,将他们导入工程。 |
| 45 | 2. 添加其他 HHDoctorSDK 依赖库。 | 45 | 2. 添加其他 HHDoctorSDK 依赖库。 |
| @@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
| 58 | 4. 在 `Build Settings` -> `Enable Bitcode 里,设置为 `No`。 | 58 | 4. 在 `Build Settings` -> `Enable Bitcode 里,设置为 `No`。 |
| 59 | 5. 如果需要在后台时保持音频通话状态,在 `Capabilities` -> `Background Modes` 里勾选 `audio, airplay, and Picture in Picture`。 | 59 | 5. 如果需要在后台时保持音频通话状态,在 `Capabilities` -> `Background Modes` 里勾选 `audio, airplay, and Picture in Picture`。 |
| 60 | 60 | ||
| 61 | -### 2.2.自动集成 | 61 | +### 1.2. 自动集成 |
| 62 | * 在 `Podfile` 文件中加入 | 62 | * 在 `Podfile` 文件中加入 |
| 63 | 63 | ||
| 64 | ```shell | 64 | ```shell |
| @@ -71,7 +71,7 @@ pod 'HHDoctorSDK', :git => "git@code.hh-medic.com:hh_public/HHDoctorSDK.ios.git" | @@ -71,7 +71,7 @@ pod 'HHDoctorSDK', :git => "git@code.hh-medic.com:hh_public/HHDoctorSDK.ios.git" | ||
| 71 | pod install | 71 | pod install |
| 72 | ``` | 72 | ``` |
| 73 | 73 | ||
| 74 | -### 2.3.调用规则 | 74 | +### 1.3. 调用规则 |
| 75 | 所有 HHDoctorSDK 业务均通过 HHMSDK 单例调用 | 75 | 所有 HHDoctorSDK 业务均通过 HHMSDK 单例调用 |
| 76 | 76 | ||
| 77 | ```swift | 77 | ```swift |
| @@ -81,7 +81,7 @@ public class HHMSDK : NSObject { | @@ -81,7 +81,7 @@ public class HHMSDK : NSObject { | ||
| 81 | } | 81 | } |
| 82 | ``` | 82 | ``` |
| 83 | 83 | ||
| 84 | -## 3.初始化 | 84 | +## 2. 初始化 |
| 85 | 在使用 HHDoctorSDK 任何方法之前,都应该首先调用初始化方法。正常业务情况下,初始化方法有仅只应调用一次。 | 85 | 在使用 HHDoctorSDK 任何方法之前,都应该首先调用初始化方法。正常业务情况下,初始化方法有仅只应调用一次。 |
| 86 | 86 | ||
| 87 | HHSDKOptions 选项参数列表 | 87 | HHSDKOptions 选项参数列表 |
| @@ -104,9 +104,9 @@ let option = HHSDKOptions(isDebug: true, isDevelop: true) | @@ -104,9 +104,9 @@ let option = HHSDKOptions(isDebug: true, isDevelop: true) | ||
| 104 | HHMSDK.default.start(option: option) | 104 | HHMSDK.default.start(option: option) |
| 105 | ``` | 105 | ``` |
| 106 | 106 | ||
| 107 | -## 4. 登录账户 | 107 | +## 3. 登录账户 |
| 108 | 在对医生视频呼叫之前,需要先登录账号信息。账号的 uuid 由和缓提供。 | 108 | 在对医生视频呼叫之前,需要先登录账号信息。账号的 uuid 由和缓提供。 |
| 109 | -### 4.1. 登录 | 109 | +### 3.1. 登录 |
| 110 | 110 | ||
| 111 | * 原型 | 111 | * 原型 |
| 112 | 112 | ||
| @@ -134,7 +134,7 @@ HHMSDK.default.login(uuid: 100001531) { (error) in | @@ -134,7 +134,7 @@ HHMSDK.default.login(uuid: 100001531) { (error) in | ||
| 134 | ``` | 134 | ``` |
| 135 | error 为登录错误信息,成功则为 nil。 | 135 | error 为登录错误信息,成功则为 nil。 |
| 136 | 136 | ||
| 137 | -### 4.2. 登出 | 137 | +### 3.2. 登出 |
| 138 | 应用层登出/注销/切换自己的账号时需要调用 HHMSDK 的登出操作,该操作会通知和缓服务器进行 APNs 推送信息的解绑操作,避免用户已登出但推送依然发送到当前设备的情况发生。 | 138 | 应用层登出/注销/切换自己的账号时需要调用 HHMSDK 的登出操作,该操作会通知和缓服务器进行 APNs 推送信息的解绑操作,避免用户已登出但推送依然发送到当前设备的情况发生。 |
| 139 | 139 | ||
| 140 | * 原型 | 140 | * 原型 |
| @@ -154,7 +154,7 @@ public class HHMSDK : NSObject { | @@ -154,7 +154,7 @@ public class HHMSDK : NSObject { | ||
| 154 | HHMSDK.default.logout() | 154 | HHMSDK.default.logout() |
| 155 | ``` | 155 | ``` |
| 156 | 156 | ||
| 157 | -## 5. 视频呼叫 | 157 | +## 4. 视频呼叫 |
| 158 | 根据实际场景的不同,可以进行成人、儿童方向的向医生咨询。 | 158 | 根据实际场景的不同,可以进行成人、儿童方向的向医生咨询。 |
| 159 | 159 | ||
| 160 | * 原型 | 160 | * 原型 |
| @@ -186,7 +186,7 @@ HHCallType 枚举列表 | @@ -186,7 +186,7 @@ HHCallType 枚举列表 | ||
| 186 | child | 儿童 | 186 | child | 儿童 |
| 187 | adult | 成人 | 187 | adult | 成人 |
| 188 | 188 | ||
| 189 | -## 6. 代理(delegate)(可选) | 189 | +## 5. 代理(delegate)(可选) |
| 190 | 代理主要用于视频过程中的状态反馈。如果不需要状态反馈,可以不考虑该代理。 | 190 | 代理主要用于视频过程中的状态反馈。如果不需要状态反馈,可以不考虑该代理。 |
| 191 | 所有的代理方法都是可选的,可以根据自己的实际需要实现不同的代理方法。 | 191 | 所有的代理方法都是可选的,可以根据自己的实际需要实现不同的代理方法。 |
| 192 | 192 | ||
| @@ -234,14 +234,14 @@ public protocol HHMVideoDelegate : NSObjectProtocol { | @@ -234,14 +234,14 @@ public protocol HHMVideoDelegate : NSObjectProtocol { | ||
| 234 | } | 234 | } |
| 235 | ``` | 235 | ``` |
| 236 | 236 | ||
| 237 | -### 6.1. 加入 | 237 | +### 5.1. 加入 |
| 238 | 代理支持同时设置多个。 | 238 | 代理支持同时设置多个。 |
| 239 | 239 | ||
| 240 | ```swift | 240 | ```swift |
| 241 | HHMSDK.default.add(delegate: self) | 241 | HHMSDK.default.add(delegate: self) |
| 242 | ``` | 242 | ``` |
| 243 | 243 | ||
| 244 | -### 6.2. 移除 | 244 | +### 5.2. 移除 |
| 245 | 245 | ||
| 246 | ```swift | 246 | ```swift |
| 247 | HHMSDK.default.remove(delegate: self) | 247 | HHMSDK.default.remove(delegate: self) |
gh-md-toc
0 → 100755
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +# | ||
| 4 | +# Steps: | ||
| 5 | +# | ||
| 6 | +# 1. Download corresponding html file for some README.md: | ||
| 7 | +# curl -s $1 | ||
| 8 | +# | ||
| 9 | +# 2. Discard rows where no substring 'user-content-' (github's markup): | ||
| 10 | +# awk '/user-content-/ { ... | ||
| 11 | +# | ||
| 12 | +# 3.1 Get last number in each row like ' ... </span></a>sitemap.js</h1'. | ||
| 13 | +# It's a level of the current header: | ||
| 14 | +# substr($0, length($0), 1) | ||
| 15 | +# | ||
| 16 | +# 3.2 Get level from 3.1 and insert corresponding number of spaces before '*': | ||
| 17 | +# sprintf("%*s", substr($0, length($0), 1)*3, " ") | ||
| 18 | +# | ||
| 19 | +# 4. Find head's text and insert it inside "* [ ... ]": | ||
| 20 | +# substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5) | ||
| 21 | +# | ||
| 22 | +# 5. Find anchor and insert it inside "(...)": | ||
| 23 | +# substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) | ||
| 24 | +# | ||
| 25 | + | ||
| 26 | +gh_toc_version="0.5.0" | ||
| 27 | + | ||
| 28 | +gh_user_agent="gh-md-toc v$gh_toc_version" | ||
| 29 | + | ||
| 30 | +# | ||
| 31 | +# Download rendered into html README.md by its url. | ||
| 32 | +# | ||
| 33 | +# | ||
| 34 | +gh_toc_load() { | ||
| 35 | + local gh_url=$1 | ||
| 36 | + | ||
| 37 | + if type curl &>/dev/null; then | ||
| 38 | + curl --user-agent "$gh_user_agent" -s "$gh_url" | ||
| 39 | + elif type wget &>/dev/null; then | ||
| 40 | + wget --user-agent="$gh_user_agent" -qO- "$gh_url" | ||
| 41 | + else | ||
| 42 | + echo "Please, install 'curl' or 'wget' and try again." | ||
| 43 | + exit 1 | ||
| 44 | + fi | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +# | ||
| 48 | +# Converts local md file into html by GitHub | ||
| 49 | +# | ||
| 50 | +# ➥ curl -X POST --data '{"text": "Hello world github/linguist#1 **cool**, and #1!"}' https://api.github.com/markdown | ||
| 51 | +# <p>Hello world github/linguist#1 <strong>cool</strong>, and #1!</p>'" | ||
| 52 | +gh_toc_md2html() { | ||
| 53 | + local gh_file_md=$1 | ||
| 54 | + URL=https://api.github.com/markdown/raw | ||
| 55 | + TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt" | ||
| 56 | + if [ -f "$TOKEN" ]; then | ||
| 57 | + URL="$URL?access_token=$(cat $TOKEN)" | ||
| 58 | + fi | ||
| 59 | + curl -s --user-agent "$gh_user_agent" \ | ||
| 60 | + --data-binary @"$gh_file_md" -H "Content-Type:text/plain" \ | ||
| 61 | + $URL | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +# | ||
| 65 | +# Is passed string url | ||
| 66 | +# | ||
| 67 | +gh_is_url() { | ||
| 68 | + case $1 in | ||
| 69 | + https* | http*) | ||
| 70 | + echo "yes";; | ||
| 71 | + *) | ||
| 72 | + echo "no";; | ||
| 73 | + esac | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +# | ||
| 77 | +# TOC generator | ||
| 78 | +# | ||
| 79 | +gh_toc(){ | ||
| 80 | + local gh_src=$1 | ||
| 81 | + local gh_src_copy=$1 | ||
| 82 | + local gh_ttl_docs=$2 | ||
| 83 | + local need_replace=$3 | ||
| 84 | + | ||
| 85 | + if [ "$gh_src" = "" ]; then | ||
| 86 | + echo "Please, enter URL or local path for a README.md" | ||
| 87 | + exit 1 | ||
| 88 | + fi | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + # Show "TOC" string only if working with one document | ||
| 92 | + if [ "$gh_ttl_docs" = "1" ]; then | ||
| 93 | + | ||
| 94 | + echo "Table of Contents" | ||
| 95 | + echo "=================" | ||
| 96 | + echo "" | ||
| 97 | + gh_src_copy="" | ||
| 98 | + | ||
| 99 | + fi | ||
| 100 | + | ||
| 101 | + if [ "$(gh_is_url "$gh_src")" == "yes" ]; then | ||
| 102 | + gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy" | ||
| 103 | + if [ "$need_replace" = "yes" ]; then | ||
| 104 | + echo | ||
| 105 | + echo "!! '$gh_src' is not a local file" | ||
| 106 | + echo "!! Can't insert the TOC into it." | ||
| 107 | + echo | ||
| 108 | + fi | ||
| 109 | + else | ||
| 110 | + local toc=`gh_toc_md2html "$gh_src" | gh_toc_grab "$gh_src_copy"` | ||
| 111 | + echo "$toc" | ||
| 112 | + if [ "$need_replace" = "yes" ]; then | ||
| 113 | + local ts="<\!--ts-->" | ||
| 114 | + local te="<\!--te-->" | ||
| 115 | + local dt=`date +'%F_%H%M%S'` | ||
| 116 | + local ext=".orig.${dt}" | ||
| 117 | + local toc_path="${gh_src}.toc.${dt}" | ||
| 118 | + local toc_footer="<!-- Added by: `whoami`, at: `date --iso-8601='minutes'` -->" | ||
| 119 | + # http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html | ||
| 120 | + # clear old TOC | ||
| 121 | + sed -i${ext} "/${ts}/,/${te}/{//!d;}" "$gh_src" | ||
| 122 | + # create toc file | ||
| 123 | + echo "${toc}" > "${toc_path}" | ||
| 124 | + echo -e "\n${toc_footer}\n" >> "$toc_path" | ||
| 125 | + # insert toc file | ||
| 126 | + if [[ "`uname`" == "Darwin" ]]; then | ||
| 127 | + sed -i "" "/${ts}/r ${toc_path}" "$gh_src" | ||
| 128 | + else | ||
| 129 | + sed -i "/${ts}/r ${toc_path}" "$gh_src" | ||
| 130 | + fi | ||
| 131 | + echo | ||
| 132 | + echo "!! TOC was added into: '$gh_src'" | ||
| 133 | + echo "!! Origin version of the file: '${gh_src}${ext}'" | ||
| 134 | + echo "!! TOC added into a separate file: '${toc_path}'" | ||
| 135 | + echo | ||
| 136 | + fi | ||
| 137 | + fi | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +# | ||
| 141 | +# Grabber of the TOC from rendered html | ||
| 142 | +# | ||
| 143 | +# $1 — a source url of document. | ||
| 144 | +# It's need if TOC is generated for multiple documents. | ||
| 145 | +# | ||
| 146 | +gh_toc_grab() { | ||
| 147 | + # if closed <h[1-6]> is on the new line, then move it on the prev line | ||
| 148 | + # for example: | ||
| 149 | + # was: The command <code>foo1</code> | ||
| 150 | + # </h1> | ||
| 151 | + # became: The command <code>foo1</code></h1> | ||
| 152 | + sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' | | ||
| 153 | + # find strings that corresponds to template | ||
| 154 | + grep -E -o '<a.*id="user-content-[^"]*".*</h[1-6]' | | ||
| 155 | + # remove code tags | ||
| 156 | + sed 's/<code>//' | sed 's/<\/code>//' | | ||
| 157 | + # now all rows are like: | ||
| 158 | + # <a id="user-content-..." href="..."><span ...></span></a> ... </h1 | ||
| 159 | + # format result line | ||
| 160 | + # * $0 — whole string | ||
| 161 | + echo -e "$(awk -v "gh_url=$1" '{ | ||
| 162 | + print sprintf("%*s", substr($0, length($0), 1)*3, " ") "* [" substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)"](" gh_url substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) ")"}' | sed 'y/+/ /; s/%/\\x/g')" | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +# | ||
| 166 | +# Returns filename only from full path or url | ||
| 167 | +# | ||
| 168 | +gh_toc_get_filename() { | ||
| 169 | + echo "${1##*/}" | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +# | ||
| 173 | +# Options hendlers | ||
| 174 | +# | ||
| 175 | +gh_toc_app() { | ||
| 176 | + local app_name="gh-md-toc" | ||
| 177 | + local need_replace="no" | ||
| 178 | + | ||
| 179 | + if [ "$1" = '--help' ] || [ $# -eq 0 ] ; then | ||
| 180 | + echo "GitHub TOC generator ($app_name): $gh_toc_version" | ||
| 181 | + echo "" | ||
| 182 | + echo "Usage:" | ||
| 183 | + echo " $app_name [--insert] src [src] Create TOC for a README file (url or local path)" | ||
| 184 | + echo " $app_name - Create TOC for markdown from STDIN" | ||
| 185 | + echo " $app_name --help Show help" | ||
| 186 | + echo " $app_name --version Show version" | ||
| 187 | + return | ||
| 188 | + fi | ||
| 189 | + | ||
| 190 | + if [ "$1" = '--version' ]; then | ||
| 191 | + echo "$gh_toc_version" | ||
| 192 | + return | ||
| 193 | + fi | ||
| 194 | + | ||
| 195 | + if [ "$1" = "-" ]; then | ||
| 196 | + if [ -z "$TMPDIR" ]; then | ||
| 197 | + TMPDIR="/tmp" | ||
| 198 | + elif [ -n "$TMPDIR" -a ! -d "$TMPDIR" ]; then | ||
| 199 | + mkdir -p "$TMPDIR" | ||
| 200 | + fi | ||
| 201 | + local gh_tmp_md | ||
| 202 | + gh_tmp_md=$(mktemp $TMPDIR/tmp.XXXXXX) | ||
| 203 | + while read input; do | ||
| 204 | + echo "$input" >> "$gh_tmp_md" | ||
| 205 | + done | ||
| 206 | + gh_toc_md2html "$gh_tmp_md" | gh_toc_grab "" | ||
| 207 | + return | ||
| 208 | + fi | ||
| 209 | + | ||
| 210 | + if [ "$1" = '--insert' ]; then | ||
| 211 | + need_replace="yes" | ||
| 212 | + shift | ||
| 213 | + fi | ||
| 214 | + | ||
| 215 | + for md in "$@" | ||
| 216 | + do | ||
| 217 | + echo "" | ||
| 218 | + gh_toc "$md" "$#" "$need_replace" | ||
| 219 | + done | ||
| 220 | + | ||
| 221 | + echo "" | ||
| 222 | + echo "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)" | ||
| 223 | +} | ||
| 224 | + | ||
| 225 | +# | ||
| 226 | +# Entry point | ||
| 227 | +# | ||
| 228 | +gh_toc_app "$@" |
-
Please register or login to post a comment