Skip to content

Latest commit

 

History

History
548 lines (482 loc) · 15.2 KB

API.md

File metadata and controls

548 lines (482 loc) · 15.2 KB

API List

JShare plugin's APIs list.

Usage

// xxx means function name, some have callbacks.
JShareModule.xxx();
  • setup() : 1.3.0 之后版本将不再需要填写平台参数。

    /**
      * iOS Only
      */
    JShareModule.setup()
  • getPlatformList(cb)

    /**
     * 获取SDK所有能用的平台名称,如要使用某个平台,必须在JGShareSDK.xml中配置。
     * Android only
     * @param {Function} callback 返回值 list 是一个数组
     */

    usage:

    JShareModule.getPlatformList((list) => {
      console.log(list);
    });
  • share(message, successCallback, failCallback)

    /**
     * 分享
     * @param {object} message = {
     *
     * platformString 必填,用于分享置不同的平台 //可以是 'wechat_session' /
     *                                               'wechat_timeLine' /
     *                                               'wechat_favourite' /
     *                                               'qq' /
     *                                               'qzone' /
     *                                               'sina_weibo' /
     *                                               'sina_weibo_contact'  /
     *                                               'facebook' /
     *                                               'facebook_messenger' /
     *                                               'twitter' /
     *                                               'jchat_pro'
     * type 必填
     *
     * {
     *  type: 'text'
     *  platform: platformString  // 分享到指定平台
     *  text: String
     *  imagePath: // 选填,本地图片地址,新浪微博(iOS 不支持这个字段)
     *  appName: // 选填,应用名称,趣聊
     *  targetPkg: // 选填,点击消息时跳转应用的包名,趣聊	
     *  targetClass: // 选填,点击消息时跳转应用的类名,趣聊	
     *  extra: // 选填,点击消息跳转到第三方应用时带的extra信息,趣聊	
     *  url: // 选填,点击消息时跳转应用的url,趣聊	
     *  callBackUrl: // 选填,点击消息跳转第三方应用失败时,回调的url,趣聊
     * }
     *
     * {
     *  type: 'image'
     *  platform: platformString  // 分享到指定平台
     *  imagePath: String   // 本地图片路径 imagePath, imageUrl imageArray 必须三选一
     *  text: String  // 选填
     *  imageUrl: String // 网络图片地址,必须以 http 或 https 开头,imagePath, imageUrl imageArray 必须三选一
     *  imageArray: [String]  // (选填: 分享到 Qzone 才提供这个字段) 如果需要分享多张图片需要这个参数,数组中问题图片路径 imagePath, imageUrl imageArray 必须三选一
     *  appName: // 选填,应用名称,趣聊
     *  targetPkg: // 选填,点击消息时跳转应用的包名,趣聊	
     *  targetClass: // 选填,点击消息时跳转应用的类名,趣聊	
     *  extra: // 选填,点击消息跳转到第三方应用时带的extra信息,趣聊	
     *  url: // 选填,点击消息时跳转应用的url,趣聊	
     *  callBackUrl: // 选填,点击消息跳转第三方应用失败时,回调的url,趣聊
     * }
     *
     * {
     *  type: 'image_text'
     *  platform: platformString  // 分享到指定平台,目前只支持趣聊
     *  appName: String // 选填,应用名称,趣聊
     *  title: String // 选填,消息标题,趣聊	
     *  text: String // 消息内容,趣聊	
     *  imageUrl: String // 选填,缩略图网络图片地址,趣聊	
     *  targetPkg: String // 选填,点击消息时跳转应用的包名,趣聊	
     *  targetClass: String // 选填,点击消息时跳转应用的类名,趣聊	
     *  extra: String // 选填,点击消息跳转到第三方应用时带的extra信息,趣聊	
     *  url: String // 选填,点击消息时跳转应用的url,趣聊	
     *  callBackUrl: String // 选填,点击消息跳转第三方应用失败时,回调的url,趣聊
     * }
     *
     * {
     *  type: 'video'
     *  platform: platformString  // 分享到指定平台
     *  title: String // 选填
     *  url: String // 视频跳转页面 url
     *  text: String  // 选填
     *  imagePath: String // 选填,缩略图,本地图片路径
    
     *  videoAssetURL: string // videoAssetURL:系统相册视频文件的 url(videoAssetURL 正确格式: assets-library://asset/asset.MOV?id=872C1D2F-97FD-4B0B-9C21-A619E4F23293&ext=MOV) (iOS only),facebook 只支持使用 videoAssetURL 来发送本地视频(不支持 url)。
     *  videoUrl: String  // QQ 空间本地视频 (iOS 不支持这个字段)
     * }
     *
     * {
     *  type: 'audio'
     *  platform: platformString  // 分享到指定平台
     *  musicUrl: String //必填 点击直接播放的 urlurl
     *  url: String //选填,点击跳转的 url
     *  imagePath: String   //选填,缩略图,本地图片路径,imagePath,imageUrl 必须二选一
     *  imageUrl: String // 选填,网络图片路径,imagePath, imageUrl 必须二选一
     *  title: String // 选填
     *  text: String  // 选填
     * }
     *
     * {
     *  type: 'file'
     *  platform: platformString  // 分享到指定平台
     *  path: String // 必填,文件路径
     *  fileExt: String // 必填,文件类型后缀
     *  tile: String
     * }
     *
     * {
     * type: 'emoticon'
     * platform: platformString  // 分享到指定平台
     * imagePath: String // 必填,本地图片路径
     * }
     *
     * {
     * type: 'app' // wechat_favourite 不支持
     * platform: platformString  // 分享到指定平台
     * url: String // 点击跳转 url
     * extInfo: String // 选填 第三方应用自定义数据
     * path: String // 选填 对应 app 数据文件
     * title: String // 选填
     * text: String // 选填
     * }
     *
     * {
     * type: 'link'
     * platform: platformString  // 分享到指定平台
     * url: String // 必填,网页 url
     * imagePath: String // 选填,本地图片路径 imagePath,imageUrl 必须二选一
     * imageUrl: String // 选填,网络图片地址 imagePath imageUrl 必须二选一,不支持Android wechat
     * title: String // 选填
     * text: String // 选填
     * }
     *
     * {
     * type: 'undefined'
     * platform: platformString  // 分享到指定平台
     * }
     *
     * @param {Function} success = function (state) {} ##
     * state = {state: String} state = 'success' / 'fail' / 'cancel' / 'unknow'
       *
     * @param {Function} fail = function (error) {} ##
     * error = {code: number, descript: String}
     */

    usage:

    var message = {
          platform: "wechat_session",
          type: "image",
          text: "JShare test text",
          imagePath: "/storage/emulated/0/DCIM/Camera/xx.jpg"
        };
    JShareModule.share(message, (map) => {
      console.log("share succeed, map: " + map);
    }, (map) => {
      console.log("share failed, map: " + map);
    })
  • getSocialUserInfo(param, successCallback, failCallback)

    /**
     * 获取社交平台用户信息
     * @param {Object} param = {
     *  platform: String //可以是 'wechat_session' / 
     *                           'wechat_timeLine' / 
     *                           'wechat_favourite' / 
     *                           'qq' / 
     *                           'qzone' / 
     *                           'sina_weibo' / 
     *                           'sina_weibo_contact' / 
     *                           'facebook' / 
     *                           'twitter' / 
     *                           'jchat_pro'
     * }
     * @param {Function} success function (userInfo) {}
     * userInfo = {
     *  name: String
     *  iconUrl: String   // 社交平台头像链接
     *  gender: String    // 'female' /  'male'
     *  response: String  // 社交平台上的原始数据, 返回 JSON 字符串
     * }
     *
     * @param {Function} fail = function (error) {} ##
     * error = {code: number, descript: String}
     */

    usage:

    var param = {
      platform: "wechat_session"
    };
    JShareModule.getSocialUserInfo(param, (map) => {
      console.log(map);
      }, (errorCode) => {
      console.log("errorCode: " + errorCode);
    });
  • isPlatformAuth(param, callback)

    /**
     * 判断某平台是否已经授权
     *
     * @param {Object} param = {
     *  platform: String //可以是 'wechat_session' /
     *                           'wechat_timeLine' /
     *                           'wechat_favourite' /
     *                           'qq' / 
     *                           'qzone' /
     *                           'sina_weibo' /
     *                           'sina_weibo_contact'  /
     *                           'facebook' /
     *                           'facebook_messenger' /
     *                           'twitter' /
     *                           'jchat_pro'
     * }
     * @param {Function} callback = (Boolean) => {}
     */

    usage:

    var param = {
    platform: "wechat_session"
    };
    JShareModule.isPlatformAuth(param, (result) => {
    console.log(param.platform + "is Auth: " + result);
    });
  • isClientValid(param, callback)

    /**
     * 判断该平台的分享是否有效
     * Android only
     * @param {Object} param = {
     *  platform: String //可以是 'wechat_session' /
     *                           'wechat_timeLine' /
     *                           'wechat_favourite' /
     *                           'qq' /
     *                           'qzone' /
     *                           'sina_weibo' /
     *                           'sina_weibo_contact'  /
     *                           'facebook' /
     *                           'facebook_messenger'/
     *                           'twitter' /
     *                           'jchat_pro'
     * }
     * @param {Function} callback = (Boolean) => {}
     */

    usage:

    var param = {
      platform: "wechat_session"
    };
    JShareModule.isClientValid(param, (result) => {
      console.log(param.platform + "is valid: " + result);
    });
  • authorize(param, successCallback, failCallback)

    /**
     * 授权接口
     * @param {Object} param = {
     *  platform: String //可以是 'wechat' /
     *                           'qq' /
     *                           'weibo' /
     *                           'facebook'/
     *                           'twitter' /
     *                           'jchat_pro'
     * }
     * @param {Function} success
     * @param {Function} fail
     */

    usage:

    var param = {
      platform: "wechat_session"
    };
    JShareModule.authorize(param, (map) => {
      console.log("Authorize succeed " + map);
    }, (errorCode) => {
      console.log("Authorize failed, errorCode : " + errorCode);
    });
  • isSupportAuthorize(param, callback) Android Only

    /**
     *  判断平台是否支持授权接口, NOTE:Android Only
     * @param {Object} param = {
     *  platform: String //可以是 'wechat_session' /
     *                           'wechat_timeLine' /
     *                           'wechat_favourite' /
     *                           'qq' /
     *                           'qzone' /
     *                           'sina_weibo' /
     *                           'sina_weibo_contact' /
     *                           'facebook' /
     *                           'facebook_messenger'/
     *                           'twitter' /
     *                           'jchat_pro'
     * }
     * @param {Function} callback = (Boolean) => {}
     */

    usage:

    var param = {
      platform: "wechat_session"
    };
    JShareModule.isSupportAuthorize(param, (result) => {
       console.log("param is Authorize: " + result);
    });
  • cancelAuthWithPlatform(param, callback)

    /**
     * 删除用户授权本地数据
     *
     * @param {Object} param = {
     *  platform: String //可以是 'wechat_session' /
     *                           'wechat_timeLine' /
     *                           'wechat_favourite' /
     *                           'qq' /
     *                           'qzone' /
     *                           'sina_weibo' /
     *                           'sina_weibo_contact'/ 
     *                           'twitter'/ 
     *                           'jchat_pro'/ 
     * }
     * @param {Function} callback = (Int) => {}
     * @code 返回码,0 表示成功删除
     */

    usage:

    var param = {
      platform: "wechat_session"
    };
    JShareModule.cancelAuthWithPlatform(param, (code) => {
      if (code === 0) {
        console.log("remove authorize succeed");
      } else {
        console.log("remove authorize failed, errorCode: " + code);
      }
    });
  • isSinaWeiboWebLogined(callback)

    /**
     * 检查不存在新浪客户端情况下的网页端是否登陆
     *
     * iOS Only
     * @param {Function} success = (Boolean) => {}
     */

    usage:

    JShareModule.isSinaWeiboWebLogined((isLogin) => {
      if (isLogin === true) {
        console.log("sina weibo is login");
      } else {
        console.log("sina weibo is not login");
      }
    });
  • sinaWeiboWebLogOut(callback)

    /**
     * 登出新浪网页端最新帐号
     *
     * iOS Only
     * @param {Function} success = (Boolean) => {}
     */

    usage:

    JShareModule.sinaWeiboWebLogOut((success) => {
      if (success === true) {
        console.log("sina weibo logout success");
      } else {
        console.log("sina weibo logout fail");
      }
    });
  • isWeChatInstalled(callback)

    /**
     * 检查是否安装微信客户端
     *
     * @param {Function} success = (Boolean) => {}
     */

    usage:

    JShareModule.isWeChatInstalled((isInstalled) => {
      if (isInstalled === true) {
        console.log("wechat is intalled");
      } else {
        console.log("wechat is not installed");
      }
    });
  • isQQInstalled(callback)

    /**
     * 检查是否存在QQ客户端
     *
     * @param {Function} success = (Boolean) => {}
     */

    usage:

    JShareModule.isQQInstalled((isInstalled) => {
      if (isInstalled === true) {
        console.log("QQ is intalled");
      } else {
        console.log("QQ is not installed");
      }
    });
  • isSinaWeiBoInstalled(callback)

    /**
     * 检查是否存在新浪微博客户端
     *
     * @param {Function} success = (Boolean) => {}
     */

    usage:

    JShareModule.isSinaWeiBoInstalled((isInstalled) => {
      if (isInstalled === true) {
        console.log("sina weibo is intalled");
      } else {
        console.log("sina weibo is not installed");
      }
    });
  • isFacebookInstalled(callback)

    /**
     * 检查是否存在 facebook 户端
     *
     * @param {Function} success = (Boolean) => {}
     */

    usage:

    JShareModule.isFacebookInstalled((isInstalled) => {
      if (isInstalled === true) {
        console.log("sina weibo is intalled");
      } else {
        console.log("sina weibo is not installed");
      }
    });
  • setDebug(param, callback),Android 建议在 MainApplication 中调用,参考 demo

    /**
     *
     * @param {Object} param = {
     *  enable: Boolean
     * }
     */

    usage:

    JShareModule.setDebug({enable: true});