{"id":40996569,"url":"https://github.com/huobanteam/app-sdk-js","last_synced_at":"2026-01-22T08:13:27.232Z","repository":{"id":57269649,"uuid":"68676253","full_name":"huobanteam/app-sdk-js","owner":"huobanteam","description":"Huoban Application JS-SDK","archived":false,"fork":false,"pushed_at":"2017-03-28T07:40:11.000Z","size":157,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-03T23:18:56.181Z","etag":null,"topics":["application","huoban","js-sdk"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huobanteam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-20T05:09:18.000Z","updated_at":"2019-12-25T04:01:26.000Z","dependencies_parsed_at":"2022-09-02T12:31:05.444Z","dependency_job_id":null,"html_url":"https://github.com/huobanteam/app-sdk-js","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/huobanteam/app-sdk-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huobanteam%2Fapp-sdk-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huobanteam%2Fapp-sdk-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huobanteam%2Fapp-sdk-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huobanteam%2Fapp-sdk-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huobanteam","download_url":"https://codeload.github.com/huobanteam/app-sdk-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huobanteam%2Fapp-sdk-js/sbom","scorecard":{"id":473662,"data":{"date":"2025-08-11","repo":{"name":"github.com/huobanteam/app-sdk-js","commit":"de000b3f54d99626c01c910af13d2c2dab977ca0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-19T14:40:03.685Z","repository_id":57269649,"created_at":"2025-08-19T14:40:03.685Z","updated_at":"2025-08-19T14:40:03.685Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28659439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application","huoban","js-sdk"],"created_at":"2026-01-22T08:13:26.542Z","updated_at":"2026-01-22T08:13:27.224Z","avatar_url":"https://github.com/huobanteam.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  Huoban App SDK ([中文版](./README_CN.md))\n\n\u003e for building applications on [Huoban](https://app.huoban.com/)\n\n***\n\n- [Import](#import)\n- [Initialize \u0026 Example](#initialize--example)\n- [SDK API](#sdk-api)\n- [Channel API](#channel-api)\n- [Client API](#client-api)\n- [Host API](#host-api)\n- [Message API](#message-api)\n\n\n## Import\n\n```js\n// ES6\nimport {client, host} from 'huoban-app-sdk'\n// or\nimport * as HuobanAppSDK from 'huoban-app-sdk'\n\n// CommonJS\nvar HuobanAppSDK = require('huoban-app-sdk')\n\n// RequireJS\ndefine(['huoban-app-sdk'], function (HuobanAppSDK) {/*...*/})\n```\n\n```html\n\u003c!-- Script, available as `window.HuobanAppSDK` --\u003e\n\u003cscript src=\"//unpkg.com/huoban-app-sdk@latest/lib/HuobanAppSDK.min.js\"\u003e\u003c/script\u003e\n```\n\n## Initialize \u0026 Example\n\n__Client: `HuobanAppSDK.client()`__\n\nCreate a app client to communicate with the host:\n\n```js\nconst client = HuobanAppSDK.client()\n\n// Normally send a message(action) to the host\nclient.send('hello', {word: 'i am a client'}).then(message =\u003e {\n  console.log(message)\n})\n```\n\n__Host: `HuobanAppSDK.host()`__\n\nCreate a host, just pass in your message handlers:\n\n```js\nconst host = HuobanAppSDK.host({\n  init: handleClientInit\n})\n\n// or use the `on` method to add handler\nhost.on('connect', (data, respond) =\u003e {\n  console.log('client connected:', data.client)\n  // use the `respond` to response data\n  respond('welcome')\n  // or refuse the connect, use the second param\n  // respond(null, 'connect refused.')\n})\n\n// add a special handler to handle all message\nhost.on('*', (action, data) =\u003e {\n  // the * handler without a `respond`\n  console.log('client send an action:', action, data)\n})\n\n// Send something directly to the special client.\n// {CLIENT} is from the `connect` handler\nhost.push({CLIENT}, 'app.change', {app_id: 123, name: ...})\n\nfunction handleClientInit (data, respond) {\n  fetchInitDataFromServer(data.app_id).then((ret) =\u003e {\n    respond(ret)\n  })\n}\n```\n\n## SDK API\n\n### `HuobanAppSDK.client(handlers) : Client`\n\nInitialize a client.\n\n- __handlers__ {Object} An object of message action/handler mappings\n\nReturns a Client_(extends Channel)_. See the [Channel API Docs](#channel-api) for more details.\n\nExample:\n\n```js\nHuobanAppSDK.client({\n  broadcast: (data, respond) =\u003e {\n    new Notification('You have a broadcast! ' + data.action)\n    respond('GOT_IT')\n  }\n})\n```\n\n### `HuobanAppSDK.host(handlers) : Host`\n\nInitialize a host.\n\n- __handlers__ {Object} An object of message action/handler mappings\n\nReturns a Host_(extends Channel)_. See the [Channel API Docs](#channel-api) for more details.\n\nExample:\n\n```js\nHuobanAppSDK.host({\n  init: handleClientInit\n})\n```\n\n### `HuobanAppSDK.isClient` _(Property)_\n\n__Boolean__ if in Huoban native APP\n\n### `HuobanAppSDK.isPC` _(Property)_\n\n__Boolean__ if in Huoban Web (https://app.huoban.com/)\n\n\n## Channel API\n\n### `channel.ready(handler)`\n\nRegister a handler to be called when the channel is opened between client and host.\n\n- __handler__ {Function} The ready handler\n\nAlthough you can register ready handlers, you can send messages before the channel is open using\n`channel.send()` and these will be queued and sent as soon as the channel is ready.\n\nExample:\n\n```js\nchannel.ready(() =\u003e {\n  application.start()\n})\n```\n\n### `channel.send(action, data) : Promise`\n\nSend a message through the channel to the host/client.\n\n- __action__ {String} The message action\n- __data__ {Any} The message data\n\nReturns a Message(Promise). See the [Message API Docs](#message-api) for more details.\n\nIf called before the channel is ready the message will be queued and sent as soon as the channel is open.\n\nExample:\n\n```js\n// Typed message, will invoke registered action handlers\nchannel.send('notify')\n\n// Typed message with data, will invoke registered action handlers\nchannel.send('openUrl', { url: 'https://app.huoban.com/' })\n```\n\n### `channel.push(action, data)`\n\nSend a message through the channel to the host/client, and without a return value.\n\n- __action__ {String} The message action\n- __data__ {Any} The message data\n\nIf called before the channel is ready the message will be queued and sent as soon as the channel is open.\n\nExample:\n\n```js\n// Typed message, will invoke registered action handlers\nchannel.push('broadcast', {action: 'refresh'})\n```\n\n### `channel.on(action, handler) : {revoke, revokes, on}`\n\nHandle an special action message.\n\n- __action__ {String} The message action\n- __handler__ {Function} The message handler\n\nThe handler receives two arguments: the `data` of the message and a `respond` function.\n\nReturns an object {revoke, revokes, on}.\n\nExample:\n\n```js\nlet connectBinder = channel.on('connect', (data, respond) =\u003e {\n  console.log('new connection: ', data)\n  respond('ok')\n})\n// remove the listener when needed\nconnectBinder.revoke()\n// or\nconnectBinder.revokes.forEach(revoke =\u003e revoke())\n```\n\n### `channel.off(action, handler)`\n\nRemove an special action handler.\n\n- __action__ {String} The message action, pass `*` will remove __all__ handlers\n- [__handler__] {Function} _(optional)_ The message handler, if omit will remove all handlers for `action`\n\nExample:\n\n```js\n // remove the special `handleClientInit` handler\nchannel.off('init', handleClientInit)\n\n// remove all `init` action's handlers\nchannel.off('init')\n\n// remove all handlers\nchannel.off('*')\n```\n\n### `channel.emit(action, data, respond)`\n\nTrigger an special action.\n\n- __action__ {String} The message action\n- [__data__] {Any} _(optional)_ The message data\n- [__respond__] {Function} _(optional)_ The message responder\n\nExample:\n\n```js\n channel.emit('connect', {app_id: 123, ...})\n```\n\n## Client API\n___Client extends Channel___\n\n### `client.init(applicationId) : Promise`\n\nGet the init data from the host. ___this should be the first call for an application___\n\n- __applicationId__ application id\n\nReturn a Promise, resolved by __data__:\n  - user {Object} current logged in user\n  - table {Object} current table\n  - ticket {String} the ticket for authenticating\n\nExample:\n\n```js\nclient.init(applicationId).then((data) =\u003e {\n  let {user, ticket, table} = data\n})\n```\n\n### `client.openWebPage(url, title)`\n\nTell host to open a new page with `url`.\n\n- __url__ {String} The web url\n- __title__ {String} The web page's title\n\n### `client.closeWebPage()`\n\nTell host to close current page.\n\n### `client.setTitle(title)`\n\nTell host to set __current__ page's title.\n\n- __title__ {String} The page title\n\n### `client.openItemDetail(itemId)`\n\nTell host to open the default item detail page.\n\n- __itemId__ {Integer} The id of the item\n\n### `client.openItemList()`\n\nTell host to open the default item list page.\n\n### `client.openItemDiff(itemId, fromRevId, toRevId, opts = {})`\n\nTell host to open the item diff component.\n\n- __itemId__ {Integer} The id of the item\n- __fromRevId__ {Integer} The id of the old reversion\n- __toRevId__ {Integer} The id of the new reversion\n- __opts__ {Object} The extra params\n  - field_id {Integer} The specified field_id to show\n  - created_by {Object} The modifier\n  - created_by_id {Integer} The modifier's id\n  - updated_on {String} The updated time\n\nExample:\n\n```js\nlet itemId = 6078229\nlet fromRevId = 7308234\nlet toRevId = 7308410\nclient.openItemDiff(itemId, fromRevId, toRevId, {\n  field_id: 3034388,\n  created_by: {name: 'airwin', user_id: 11003, avatar: {}, ...},\n  created_by_id: 11003,\n  updated_on: '2016-07-31 11:22:33'\n})\n```\n\n### `client.openFilter(table, filters, fn)`\n___this method use the `fn` to receive callback, not return a Promise___\n\nTell host to open the native filter component.\n\n- __table__ {Object} The Table Info\n- __filters__ {Object} The specialed filters\n- __fn__ {Function} handler, fn(data, error)\n  - data {Object} data of callback,  eg: _{filters: {and: [{field: 110001, query: {..}}, ..]}}_\n     - filters {Object} selected filters\n  - error {Object} error info\n    eg: _{cancelled: true}_ for user cancel the operation, _{message: 'default value error'}_ for some actual error\n     - cancelled {Boolean} true for user cancel the operation\n     - message {String} error message\n\nExample:\n\n```js\nclient.openFilter(table, null, (data) =\u003e {\n  console.log('filters changed:', data.filters)\n})\n```\n\n### `client.openUserPicker(opts, fn)`\n___this method use the `fn` to receive callback, not return a Promise___\n\nTell host to open the user picker component.\n\n- __opts__ {Object} The picker options\n  - values {Array} selected users's id, eg: [11001, 11003]\n  - multi {Boolean} if allow select multiple users\n  - required {Boolean} if must select one user at least\n  - title {String} the picker's title\n  - placement {String} _(web only)_ picker's position relative to the target, can be: left-bottom/right-bottom/left-top/right-top,  default: 'right-bottom'\n  - width {Integer} _(web only)_ picker's layer's width\n- __fn__ {Function} handler, fn(data, error)\n  - data {Object} data of callback\n    eg: _{users: [{user_id: 11001, name: 'test1'}, {user_id: 11003, name: 'test2'}, ...]}_\n     - users {Array} selected users\n  - error {Object} error info\n    eg: _{cancelled: true}_ for user cancel the operation, _{message: 'default value error'}_ for some actual error\n     - cancelled {Boolean} true for user cancel the operation\n     - message {String} error message\n\nExample:\n\n```js\nclient.openUserPicker({multi: true, values: [11001, 11003]}, (data) =\u003e {\n  console.log('users picked:', data.users)\n})\n```\n\n### `client.openDatePicker(opts, fn)`\n___this method use the `fn` to receive callback, not return a Promise___\n\nTell host to open the date picker component.\n\n- __opts__ {Object} The picker options\n  - [value] {String} _(optional)_ default datetime\n  - [type] {String} select type: date/time/datetime\n  - [showClear] {Boolean} if show a `clear` button to clear current datetime\n  - [showToday] {Boolean} if show a `today` button to select today\n  - [range] {Object} range of the selectable date, eg: _{gte: '2016-08-01', lte: '2016-11-11'}_\n  - placement {String} _(web only)_ picker's position relative to the target, can be: left-bottom/right-bottom/left-top/right-top,  default: 'right-bottom'\n- __fn__ {Function} handler, fn(data, error)\n  - data {Object} data of callback, eg: _{datetime: '2016-07-28 12:33', date: '2016-07-28', time: '12:33'}_\n     - [datetime] {String} _(optional)_ selected datetime\n     - [date] {String} _(optional)_ selected date\n     - [time] {String} _(optional)_ selected time\n  - error {Object} error info\n    eg: _{cancelled: true}_ for user cancel the operation, _{message: 'default value error'}_ for some actual error\n     - cancelled {Boolean} true for user cancel the operation\n     - message {String} error message\n\nExample:\n\n```js\nclient.openDatePicker({value: '2016-07-27', type: 'date'}, (data) =\u003e {\n  console.log('date picked:', data.date)\n})\n```\n\n### `client.openRichEditor(opts, fn)`\n___this method use the `fn` to receive callback, not return a Promise___\n\nTell host to open the rich text editor.\n\n- __opts__ {Object} The picker options\n  - title {String} editor's title\n  - [value] {String} _(optional)_ default text\n- __fn__ {Function} handler, fn(data, error)\n  - data {Object} data of callback, eg: _{value: '\u003cp\u003eabc\u003c/p\u003e'}_\n     - value {String} edited text\n  - error {Object} error info\n    eg: _{cancelled: true}_ for user cancel the operation, _{message: 'default value error'}_ for some actual error\n     - cancelled {Boolean} true for user cancel the operation\n     - message {String} error message\n\n### `client.openShare(opts, fn)`\n___this method use the `fn` to receive callback, not return a Promise___\n\nTell host to open the share component.\n\n- __opts__ {Object} The share options\n  - [title] {String} share title\n  - [content] {String} description of the share\n  - [image] {String} share image's url\n  - [url] {String} the link to share\n  - [type] {String} share type, can be: url(default)/image(share image blob)\n  - [content_info] {Object} extra info, eg: {size: 1024} (when type is 'image')\n  - [via] {String} specified share with, can be: wechat/wechat_timeline/qq/weibo/clipboard/browser/tongren\n- __fn__ {Function} handler, fn(data, error)\n  - data {Object} data of callback, eg: _{via: 'wechat'}_\n     - [via] {String} the app's name which shared with, can be: wechat/wechat_timeline/qq/weibo/clipboard/browser/tongren\n  - error {Object} error info\n    eg: _{cancelled: true}_ for user cancel the operation, _{message: 'default value error'}_ for some actual error\n     - cancelled {Boolean} true for user cancel the operation\n     - message {String} error message\n\nExample:\n\n```js\nclient.openShare({title: 'huoban', content: 'welcome', url: 'https://app.huoban.com'}, (data, error) =\u003e {\n  if (!error) {\n    console.log('share successed with:', data.via)\n  } else {\n    console.log('share failed.')\n  }\n})\n```\n\n### `client.getSpaceMembers(opts) : Promise`\n\nget the full list of space's members from host.\n\n- __opts__ {Object} options\n  - [keyword] {String} _(optional)_ search keyword\n\nReturn a Promise, resolved by __data__:\n  - members {Array} list of members, _eg: [{name: 'test1', user_id: 11003, avatar:..}, ..]_\n\nExample:\n\n```js\nclient.getSpaceMembers({keyword: 'air'}).then((data) =\u003e {\n  console.log('got members:', data.members)\n})\n```\n\n### `client.openAttachment(fileInfo)`\n\nTell host to show an attachment.\n\n- __fileInfo__ {Object} The attachment info\n\n### `client.genQRCode(text) : Promise`\n\ngenerate a QRCode.\n\n- __text__ {Object} text to generate\n\nReturn a Promise, resolved by __data__:\n  - dataURL {String} base64 encoded string for using in images' src\n\nExample:\n\n```js\nclient.genQRCode('hello world').then((data) =\u003e {\n  console.log('got dataURL:', data.dataURL)\n})\n```\n\n### `client.scanQRCode(opts) : Promise`\n\nscan a QRCode. _(native only)_\n\n- __opts__ {Object} options\n  - needResult {Boolean} true for return the result of the scanned QRCode\n\nReturn a Promise, resolved by __data__:\n  - result {String} result of scan\n\nExample:\n\n```js\nclient.scanQRCode().then((data) =\u003e {\n  console.log('got result:', data.result)\n})\n```\n\n### `client.getLocation(opts = {}, fn)`\n___this method use the `fn` to receive callback, not return a Promise___\n\nrequest the current location.\n\n- __opts__ {Object} options\n  - [position] {Object} _(optional)_ current position (gcj02) _eg: {lng: 116.397428, lat: 39.90923}_\n  - enableHighAccuracy {Boolean} request high accuracy (GPS), default: true\n  - timeout {Integer} timeout (ms), default: 10000\n  - convert {Boolean} if convert (wgs84 to gcj02), default: true\n  - title {String} title to show\n\n- __fn__ {Function} handler, fn(data, error)\n  - data {Object} data of callback\n     - location {Object} current location _eg: {name: 'xx', address: 'xx', distance: 10, lng: 116.32, lat: 40.033}_\n  - error {Object} error info\n    eg: _{cancelled: true}_ for user cancel the operation, _{message: 'default value error'}_ for some actual error\n     - cancelled {Boolean} true for user cancel the operation\n     - message {String} error message\n\nExample:\n\n```js\nclient.getLocation({}, (data, error) =\u003e {\n  console.log('got location:', data, error)\n})\n```\n\n### `client.openUserProfile(userId, opts)`\n\nTell host to open an user's profile card.\n\n- __userId__ {Integer} The User's user_id\n- __opts__ {Object} options\n  - placement {String} _(web only)_ picker's position relative to the target, can be: left-bottom/right-bottom/left-top/right-top/bottom/top,  default: 'bottom'\n\n### `client.broadcast(action, data)`\n\nBroadcast an action to all _other_ clients.\n\n- __action__ {String} The broadcast action\n- [__data__] {Any} _(optional)_ The broadcast data\n\n### `client.setPageConfig(config)`\n\nset the current page's behavior. _(native only)_\n\n- __config__ {Object}\n  - landscape {Object} behavior when screen turned to landscape\n     eg: _{nav_bar: false, bottom_bar: false}_\n     - nav_bar {Boolean} if show the navigation bar\n     - bottom_bar {Boolean} if show the botttom bar\n\n### `client.setNavigationBarVisibility(isVisible)`\n\nTell host to toggle the navbar. _(native only)_\n\n- __isVisible__ {Boolean} visible\n\n### `client.setBottomToolBarVisibility(isVisible)`\n\nTell host to toggle the toolbar. _(native only)_\n\n- __isVisible__ {Boolean} visible\n\n### `client.installApplication(applicationId)`\n\nTell host to install an application. _(native only)_\n\n- __applicationId__ {Integer} application's id\n\n\n## Host API\n___Host extends Channel___\n\n### `host.send(client, action, data) : Promise`\n\nGet the init data from the host. ___this should be the first call for an application___\n\n- __client__  the client id _(from the `connect` event handler)_\n- __action__ the action name\n- __[data]__  _(optional)_ the action data\n\n### `host.push(client, action, data)`\n\nsame as the `send` but without a return.\n\n- __client__  the client id _(from the `connect` event handler)_\n- __action__ the action name\n- __[data]__  _(optional)_ the action data\n\n\n### `host.broadcast(action, data, applicationId)`\n\nbroadcast an action to __all__ clients\n\n- __action__ the action name\n- __[data]__  _(optional)_ the action data\n- __[applicationId]__  _(optional)_ special an application by id\n\n\n## Message API\n\n### `message.then(handler)`\n\nRegister a handler to receive the response to a message.\n\n- __handler__ {Function} Response handler\n\nExample:\n\n```js\n// In host\nHuobanAppSDK.host({\n  init: (data, respond) =\u003e {\n    // may some async action\n    fetchSomething(data.app_id).then((ret) =\u003e {\n      respond({ticket: ret.ticket, user: {name: 'test1', ...}})\n    })\n  }\n})\n\n// In client\nconst client = HuobanAppSDK.client()\nclient.send('init', { app_id: 100117 }).then((data) =\u003e {\n  console.log(data.ticket, data.user, data.table)\n})\n```\n\n### `respond([data])`\n\nSend a response to a received message.\n\nThis function is passed as the second argument to message handlers.\n\n- [__data__] {Any} _(optional)_ The data to respond to the message with.\n\n## Author \u0026 License\n\ncreated by [airwin](https://github.com/airwin) and released under the MIT license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuobanteam%2Fapp-sdk-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuobanteam%2Fapp-sdk-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuobanteam%2Fapp-sdk-js/lists"}