更新记录

1.2.0(2021-04-07)

.

1.1.3(2020-06-03)

iOS

  1. 新增google授权
  2. 新增line分享授权
  3. 新增分享菜单
  4. 支持copy、print
  5. 新增ShareSDK.js支持各平台定制化
  6. 去除隐私协议二次弹框

详情请看demo

andriod

  1. 新增google授权
  2. 去除隐私协议二次弹框

1.1.0(2020-03-02)

修复Bug;增加隐私协议接口

查看更多

平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 11.0 armeabi-v7a:未测试,arm64-v8a:未测试,x86:未测试 适用版本区间:9 - 14

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


注意:安卓端目前只支持本地集成。IOS端支持云端集成和本地集成。

本地插件集成文档

一、下载插件

下载离线插件,放在项目的nativeplugins文件夹中。(若没有则创建此目录) 目录结构如下:

二、引用插件

打开要使用ShareSDK插件的项目,把第一步下载的插件放入nativeplugins文件夹,然后打开manifest.json文件,点击App原生插件配置,点击选择本地插件,勾选mob-sharesdk,如下图所示:

三、填写配置信息

按第二部引入mob-sharesdk插件后,在App原生插件配置中配置MobAppKey以及各平台key信息,用不到可以不配置

安卓端(only)

安卓端还需要mob-sharesdk/android下新建assets目录,并在新创建的assets目录中创建名为ShareSDK.xml的文件,如下图:

ShareSDK.xml文件内容示例如下,实际使用时,需要把各平台appkey等信息替换为自己的,不用的平台可以删除:

<?xml version="1.0" encoding="utf-8"?>
<DevInfor>
<SinaWeibo Id="1" SortId="59" AppKey="568898243" AppSecret="38a4f8204cc784f81f9f0daaf31e02e3" ShareByAppClient="true" Enable="true" RedirectUrl="http://www.sharesdk.cn" />
<TencentWeibo Id="2" SortId="2" AppKey="801307650" AppSecret="ae36f4ee3946e1cbb98d6965b0b2ff5c" Enable="true" RedirectUri="http://sharesdk.cn" />
<Douban Id="16" SortId="16" Enable="true" ApiKey="031a96a3aa8b28af094fc3eaffa17a0d" Secret="2e675e730571b75d" RedirectUri="http://mob.com" />
<QZone Id="3" SortId="3" AppId="100371282" AppKey="aed9b0303e3ed1e27bae87c33761161d" ShareByAppClient="true" BypassApproval="false" Enable="true" />
<Renren Enable="false" />
<KaiXin Enable="false" />
<Facebook Id="8" SortId="8" ShareByAppClient="true" Enable="true" ConsumerKey="2796236850615578" ConsumerSecret="7d353609b517b23a80dcb057995ef30c" RedirectUrl="https://mob.com" />
<Twitter Id="9" SortId="9" ShareByAppClient="true" Enable="true" ConsumerKey="viOnkeLpHBKs6KXV7MPpeGyzE" ConsumerSecret="NJEglQUy2rqZ9Io9FcAU9p17omFqbORknUpRrCDOK46aAbIiey" CallbackUrl="http://mob.com" />
<Evernote Id="19" SortId="19" HostType="sandbox" ShareByAppClient="true" Enable="true" ConsumerKey="sharesdk-7807" ConsumerSecret="d05bf86993836004" />
<FourSquare Enable="false" />
<GooglePlus Id="21" SortId="21" OfficialVersion="default" ShareByAppClient="true" Enable="true" ClientID="236300675100-am5pm8km7md1memjevq8rl9pg5c4s4b8.apps.googleusercontent.com" RedirectUrl="http://localhost" />
<Instagram Id="28" SortId="28" ShareByAppClient="true" Enable="true" ClientId="ff68e3216b4f4f989121aa1c2962d058" ClientSecret="1b2e82f110264869b3505c3fe34e31a1" RedirectUri="http://sharesdk.cn" />
<LinkedIn Id="20" SortId="20" ShareByAppClient="true" Enable="true" ApiKey="ejo5ibkye3vo" SecretKey="cC7B2jpxITqPLZ5M" RedirectUrl="http://sharesdk.cn" />
<Tumblr Enable="false" />
<Email Id="12" SortId="12" Enable="true" />
<ShortMessage Id="13" SortId="13" Enable="true" />
<Wechat Id="4" SortId="4" AppId="wx4868b35061f87885" AppSecret="64020361b8ec4c99936c0e3999a9f249" WithShareTicket="true" BypassApproval="false" Enable="true" />
<WechatMoments Id="5" SortId="5" AppId="wx4868b35061f87885" AppSecret="64020361b8ec4c99936c0e3999a9f249" BypassApproval="false" Enable="true" />
<QQ Id="7" SortId="7" AppId="100371282" AppKey="aed9b0303e3ed1e27bae87c33761161d" ShareByAppClient="true" BypassApproval="false" Enable="true" />
<Instapaper Id="38" SortId="38" Enable="true" ConsumerKey="4rDJORmcOcSAZL1YpqGHRI605xUvrLbOhkJ07yO0wWrYrc61FA" ConsumerSecret="GNr1GespOQbrm8nvd7rlUsyRQsIo3boIbMguAl9gfpdL0aKZWe" />
<Pocket Id="37" SortId="37" Enable="true" ConsumerKey="32741-389c565043c49947ba7edf05" />
<YouDao Id="17" SortId="17" HostType="product" Enable="true" ConsumerKey="dcde25dca105bcc36884ed4534dab940" ConsumerSecret="d98217b4020e7f1874263795f44838fe" RedirectUri="http://www.sharesdk.cn/" />
<Pinterest Enable="false" />
<Flickr Enable="false" />
<Dropbox Enable="false" />
<VKontakte Id="27" SortId="27" ShareByAppClient="true" Enable="true" ApplicationId="3921561" />
<WechatFavorite Id="6" SortId="6" AppId="wx4868b35061f87885" AppSecret="64020361b8ec4c99936c0e3999a9f249" BypassApproval="false" Enable="true" />
<Yixin Enable="false" />
<YixinMoments Enable="false" />
<Mingdao Enable="false" />
<Line Id="32" SortId="32" callbackscheme="lineauth" Enable="true" ChannelID="1639219273" ChannelSecret="58faad55ffce8bf8f63b59fe6fb702ae" RedirectUri="https://www.mob.com/" />
<WhatsApp Id="35" SortId="35" Enable="true" />
<KakaoTalk Id="33" SortId="33" AppKey="48d3f524e4a636b08d81b3ceb50f1003" Enable="true" />
<KakaoStory Id="34" SortId="34" AppKey="48d3f524e4a636b08d81b3ceb50f1003" Enable="true" />
<FacebookMessenger Id="39" SortId="39" AppId="107704292745179" OfficialVersion="default" Enable="true" />
<Alipay Id="50" SortId="50" AppId="2015072400185895" Enable="true" />
<AlipayMoments Id="51" SortId="51" AppId="2015072400185895" Enable="true" />
<Dingding Id="52" SortId="52" AppId="dingoanxyrpiscaovl4qlw" BypassApproval="false" Enable="true" />
<Youtube Id="53" SortId="53" AppSecret="AIzaSyAO06g-0TDpHcsXXO918a7QE3Zdct2bB5E" ShareByAppClient="true" Enable="true" ClientID="370141748022-bicrnsjfiije93bvdt63dh3728m4shas.apps.googleusercontent.com" RedirectUrl="http://localhost" />
<Meipai Id="54" SortId="54" AppSecret="y9ym6rrjjijtkt23qtsc" ShareByAppClient="true" Enable="true" ClientID="1089867596" />
<Telegram Id="47" SortId="47" AppKey="782826033" Enable="true" RedirectUrl="http://www.mob.com" />
<Cmcc Id="55" SortId="55" AppId="300011860247" AppKey="2D464D8BFCE73A44B4F9DF95A2FDBE1C" />
<Reddit Id="56" SortId="56" AppKey="MExDxPuTCtFiRw" RedirectUrl="http://www.sharesdk.cn" />
<Telecom Id="57" SortId="57" AppKey="8148612606" AppSecret="mCltrhUqwshFa86egDTs0491ibaAulKA" Enable="true" RedirectUrl="http://www.sharesdk.cn" />
<Accountkit Id="58" SortId="58" AppKey="579465512480462" AppSecret="8a6383652dd9f23fb0994f03d350d0ca" Enable="true" RedirectUrl="http://www.sharesdk.cn/" />
<Douyin Id="59" SortId="1" AppKey="aw9ivykfjvi4hpwo" AppSecret="42b4caa6bda60bd49f05f06d0a4956e1" Enable="true" />
<Wework Id="60" SortId="60" AppKey="wwa21eaecf93f0e3ba" AppSecret="dW7e27P7Hc8NiYdRxnbTeOLgfI1ugR72e-PM8uusq2s" AgentId="1000012" Schema="wwautha21eaecf93f0e3ba000012" />
<HWAccount Enable="false" />
<Oasis Enable="false" />
<XMAccount Enable="false" />
<SnapChat Enable="false" />
<Kuaishou Id="68" SortId="68" Enable="true" />
<Littleredbook Enable="false" />
<Watermelonvideo Enable="false" />
<Tiktok Enable="false" />
</DevInfor>


四、打自定义基座

  1. 点击HBuilder X菜单栏的发行→原生App-云打包

  1. 按图填写App信息,确认无误后点击打包

  1. 如图所示,打包成功

五、接口示例

分享微信小程序(安卓only)

var _this = this
pluginMobShare.generalShare({
    platName: SSDKPlatformID.WeChat,
    params: {
        text: 'text',
        title: "title",
        wxUserName: "gh_52568203455c",
        wxPath: "pages/index/index",
        wxMiniProgramType: 0,//0-正式,1-开发,2-体验
        url: 'https://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4',
        imageUrl: "http://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg"
    },
    shareType: SSDKContentType.ShareWxMiniProgram,
}, result => {
    const msg = JSON.stringify(result);
    _this.showAlertAndLog(msg);
});

打开微信小程序(安卓only)

var _this = this
pluginMobShare.generalShare({
    platName: SSDKPlatformID.WeChat,
    params: {
        text: 'text',
        title: "title",
        wxUserName: "gh_52568203455c",
        wxPath: "pages/index/index",
        //0-正式,1-开发,2-体验
        wxMiniProgramType: 0,
        url: 'https://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4',
        imageUrl: "http://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg"
    },
    shareType: SSDKContentType.OpenWxMiniProgram,
}, result => {
    const msg = JSON.stringify(result);
    _this.showAlertAndLog(msg);
});

单平台分享

var _this = this
pluginMobShare.generalShare({
    platName: SSDKPlatformID.WeChat,
    params: {
        text: 'text',
        title: "title",
        url: 'https://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4',
        imageUrl: "http://img1.2345.com/duoteimg/qqTxImg/2012/04/09/13339485237265.jpg"
    },
    shareType: SSDKContentType.Video,
}, result => {
    const msg = JSON.stringify(result);
    _this.showAlertAndLog(msg);
});

获取隐私协议内容

pluginMobShare.getPrivacyPolicy({
    isUrl: 'true',
}, result => {
    const modal = uni.requireNativePlugin('modal');
    const msg = JSON.stringify(result);
    modal.toast({
        message: msg,
        duration: 2,
    });
});

回传隐私协议结果

//isurl参数如果传入字符串‘true’则表示接受隐私协议
pluginMobShare.submitPrivacyGrantResult({
    granted: true,
}, result => {
    const modal = uni.requireNativePlugin('modal');
    const msg = JSON.stringify(result);
    modal.toast({
        message: msg,
        duration: 2,
    });
});

分享平台是否安装

pluginMobShare.isInstallPlatform({
    platName: SSDKPlatformID.WeChat,
}, result => {
    const modal = uni.requireNativePlugin('modal');
    modal.toast({
        message: result,
        duration: 2,
    });
});

更多分享示例参考githubDemo

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

Android:imei iOS:手机型号、系统版本 服务器地址:api.share.mob.com 数据用途:收集bug日志、错误信息 插件使用的ShareSDK产品会采集数据,此产品的隐私策略条款,可以参考:http://www.mob.com/about/policy

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

作者未提供license.md

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问