快应用 分享

2020-08-10 13:48 更新

接口声明

{"name": "system.share"}
导入模块

import share from '@system.share' 或 const share = require('@system.share')

接口定义

share.share(OBJECT)

分享数据到其他app

参数:

参数名 类型 必填 说明
type String 数据的MIME TYPE,要求字母全小写
data String 分享的数据:1. 如果 type 是 text/ 开头的mimetype(如 text/plain ),则 data 是要分享的文本内容;2. 如果 type 是其他值,则 data 是要分享的文件路径。支持三种文件路径:1. 通过fetch.fetch 下载的文件路径;2. 通过file.save或list获得的文件路径;3. 以/开头的应用内部的资源文件。
success Function 成功回调。因为大部分 android app 都没有正确的返回分享状态,所以即使分享成功了,也可能执行 cancel 回调,而不是 success 回调。
fail Function 失败回调
cancel Function 取消回调
complete Function 执行结束后的回调

示例:

share.share({
  type: 'text/html',
  data: '<b>bold</b>',
  success: function (data) {
    console.log('handling success')
  },
  fail: function (data, code) {
    console.log(`handling fail, code = ${code}`)
  }
})

后台运行限制

禁止使用。后台运行详细用法参见 后台运行脚本


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号