ibeacon.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  6. <meta name="HandheldFriendly" content="true">
  7. <meta name="MobileOptimized" content="320">
  8. <title>iBeacon Document</title>
  9. <link rel="stylesheet" type="text/css" href="res/doc.css" charset="utf-8">
  10. <link rel="stylesheet" type="text/css" href="res/prettify.sons.css" charset="utf-8">
  11. <script type="text/javascript" src="res/doc.js" charset="utf-8"></script><script type="text/javascript" src="res/prettify.js" charset="utf-8"></script>
  12. </head>
  13. <body><div id="content" class="content">
  14. <h1><a name="plus.ibeacon">ibeacon</a></h1>
  15. <p>
  16. iBeacon模块用于搜索附件的iBeacon设备。</p>
  17. <h2>方法:</h2>
  18. <ul>
  19. <li>
  20. <a href="#plus.ibeacon.startBeaconDiscovery">startBeaconDiscovery</a>: 开始搜索附近的iBeacon设备</li>
  21. <li>
  22. <a href="#plus.ibeacon.stopBeaconDiscovery">stopBeaconDiscovery</a>: 停止搜索附近的iBeacon设备</li>
  23. <li>
  24. <a href="#plus.ibeacon.getBeacons">getBeacons</a>: 获取已搜索到的iBeacon设备</li>
  25. <li>
  26. <a href="#plus.ibeacon.onBeaconUpdate">onBeaconUpdate</a>: 监听iBeacon设备更新</li>
  27. <li>
  28. <a href="#plus.ibeacon.onBeaconServiceChange">onBeaconServiceChange</a>: 监听iBeacon服务状态变化</li>
  29. </ul>
  30. <h2>对象:</h2>
  31. <ul><li>
  32. <a href="#plus.ibeacon.IBeaconInfo">IBeaconInfo</a>: iBeacon设备信息</li></ul>
  33. <h2>回调方法:</h2>
  34. <ul>
  35. <li>
  36. <a href="#plus.ibeacon.IBeaconSuccessCallback">IBeaconSuccessCallback</a>: 成功回调函数</li>
  37. <li>
  38. <a href="#plus.ibeacon.IBeaconFailCallback">IBeaconFailCallback</a>: 失败回调函数</li>
  39. <li>
  40. <a href="#plus.ibeacon.IBeaconCompleteCallback">IBeaconCompleteCallback</a>: 操作完成回调函数</li>
  41. <li>
  42. <a href="#plus.ibeacon.IBeaconUpdateCallback">IBeaconUpdateCallback</a>: 获取iBeacon设备信息回调函数</li>
  43. <li>
  44. <a href="#plus.ibeacon.IBeaconServiceChangeCallback">IBeaconServiceChangeCallback</a>: iBeacon服务状态变化回调函数</li>
  45. </ul>
  46. <h2>权限:</h2>
  47. <p>5+功能模块(permissions)</p>
  48. <pre class="prettyprint linenums">
  49. {
  50. // ...
  51. "permissions":{
  52. // ...
  53. "iBeacon": {
  54. "description": "iBeacon"
  55. }
  56. }
  57. }
  58. </pre>
  59. <h1><a name="plus.ibeacon.IBeaconInfo">IBeaconInfo</a></h1>
  60. <p>iBeacon设备信息</p>
  61. <pre class="prettyprint linenums">
  62. interface IBeaconInfo {
  63. readonly attribute String uuid;
  64. readonly attribute String major;
  65. readonly attribute String minor;
  66. readonly attribute Number proximity;
  67. readonly attribute Number accuracy;
  68. readonly attribute Number rssi;
  69. }
  70. </pre>
  71. <h2>属性:</h2>
  72. <ul>
  73. <li>uuid: <em>(<font class="type">String</font>
  74. 类型
  75. )</em>iBeacon设备广播的uuid<br>
  76. </li>
  77. <li>major: <em>(<font class="type">String</font>
  78. 类型
  79. )</em>iBeacon设备的主id<br>
  80. </li>
  81. <li>minor: <em>(<font class="type">String</font>
  82. 类型
  83. )</em>iBeacon设备的次id<br>
  84. </li>
  85. <li>proximity: <em>(<font class="type">Number</font>
  86. 类型
  87. )</em>iBeacon设备的距离<br>
  88. </li>
  89. <li>accuracy: <em>(<font class="type">Number</font>
  90. 类型
  91. )</em>iBeacon设备的距离精度信息<br>
  92. </li>
  93. <li>rssi: <em>(<font class="type">String</font>
  94. 类型
  95. )</em>iBeacon设备的信号强度<br>
  96. </li>
  97. </ul>
  98. <h1><a name="plus.ibeacon.IBeaconSuccessCallback">IBeaconSuccessCallback</a></h1>
  99. <p>成功回调函数</p>
  100. <pre class="prettyprint linenums">
  101. void onSuccess(event){
  102. }
  103. </pre>
  104. <h2>说明:</h2>
  105. <p class="des">
  106. 不同接口触发的成功回调参数event包含的属性存在差异,具体参考对应的接口描述说明。
  107. </p>
  108. <h2>参数:</h2>
  109. <ul><li>event:
  110. <em>(
  111. <font class="type">json</font>
  112. )
  113. 必选 </em>回调参数<br>
  114. 回调参数包含的属性由调用接口决定,具体参考对应的接口描述说明。
  115. </li></ul>
  116. <h2>返回值:</h2>
  117. <font class="type">void</font>
  118. : 无<h1><a name="plus.ibeacon.IBeaconFailCallback">IBeaconFailCallback</a></h1>
  119. <p>失败回调函数</p>
  120. <pre class="prettyprint linenums">
  121. function void onFail(DOMException error){
  122. // Handle error
  123. var code = error.code; // 错误编码
  124. var message = error.message; // 错误描述信息
  125. }
  126. </pre>
  127. <h2>参数:</h2>
  128. <ul><li>error:
  129. <em>(
  130. <font class="type">DOMException</font>
  131. )
  132. 必选 </em>回调参数,错误信息<br>
  133. 可通过error.code(Number类型)获取错误编码;
  134. 可通过error.message(String类型)获取错误描述信息。
  135. </li></ul>
  136. <h2>返回值:</h2>
  137. <font class="type">void</font>
  138. : 无<h1><a name="plus.ibeacon.IBeaconCompleteCallback">IBeaconCompleteCallback</a></h1>
  139. <p>操作完成回调函数</p>
  140. <pre class="prettyprint linenums">
  141. function void onComplete(event){
  142. }
  143. </pre>
  144. <h2>说明:</h2>
  145. <p class="des">
  146. 调用成功或失败都会触发此回调。
  147. </p>
  148. <h2>参数:</h2>
  149. <ul><li>event:
  150. <em>(
  151. <font class="type">json</font>
  152. )
  153. 可选 </em>回调参数<br>
  154. 调用成功时回调参数与IBeaconSuccessCallback一致,调用失败时回调参数与IBeaconFailCallback一致。
  155. </li></ul>
  156. <h2>返回值:</h2>
  157. <font class="type">void</font>
  158. : 无<h1><a name="plus.ibeacon.IBeaconUpdateCallback">IBeaconUpdateCallback</a></h1>
  159. <p>获取iBeacon设备信息回调函数</p>
  160. <pre class="prettyprint linenums">
  161. void onSuccess(event){
  162. // 通过beacons获取iBeacon设备列表信息
  163. var beacons = event.beacons;
  164. }
  165. </pre>
  166. <h2>参数:</h2>
  167. <ul><li>event:
  168. <em>(
  169. <font class="type">JSON</font>
  170. )
  171. 必选 </em>设备信息<br>
  172. 可通过event.beacons(Array&lt;IBeaconInfo&gt;类型)获取iBeacon设备列表信息。
  173. </li></ul>
  174. <h2>返回值:</h2>
  175. <font class="type">void</font>
  176. : 无<h1><a name="plus.ibeacon.IBeaconServiceChangeCallback">IBeaconServiceChangeCallback</a></h1>
  177. <p>iBeacon服务状态变化回调函数</p>
  178. <pre class="prettyprint linenums">
  179. void onSuccess(event){
  180. // 通过available、discovering获取iBeacon服务状态
  181. var available = event.available;
  182. var discovering = event.discovering;
  183. }
  184. </pre>
  185. <h2>参数:</h2>
  186. <ul><li>event:
  187. <em>(
  188. <font class="type">JSON</font>
  189. )
  190. 必选 </em>iBeacon服务状态信息<br>
  191. 可通过event.available(Boolean类型)获取iBeacon服务目前是否可用;
  192. 可通过event.discovering(Boolean类型)获取是否处于搜索iBeacon设备状态。
  193. </li></ul>
  194. <h2>返回值:</h2>
  195. <font class="type">void</font>
  196. : 无<br><br>
  197. </div></body>
  198. </html>