Git Product home page Git Product logo

eros-plugin-ios-wxshare's Introduction

bmWXShare

功能简介:基于友盟ShareSDK实现,微信分享(分享到朋友圈,微信好友)及微信授权登录; 在使用分享之前,还需要一些配置
1.首先请到友盟平台注册App获取AppKey;
2.iOS平台请参考友盟的教程配置SSO白名单、及 URL Scheme;
3.为了让大家更灵活的根据产品定制样式,分享的页面面板需要自己写。

集成方式

  1. 打开iOS目录工程目录/platforms/ios/WeexEros,编辑Podfile文件,添加ErosPluginWXShare组件的引用,添加代码如下,注意版本号改为最新的版本

    def common
    	...忽略其他库的引用
    	# 在这里添加引用 ErosPluginWXShare
    	pod 'ErosPluginWXShare', :git => 'https://github.com/bmfe/eros-plugin-ios-wxshare.git', :tag => '版本'
    end
    target 'WeexEros' do
    	common
    end
  2. 在终端中cd到此目录下执行 pod update,等待命令执行完毕,重新运行项目,如果没有报错则说明ErosPluginWXShare组件集成成功;

使用

引用Module

var bmWXShare = weex.requireModule('bmWXShare')

API

  • 判断是否安装微信app isInstallWXApp()

    在使用微信分享或授权登录之前应该判断是否安装了微信app,如果没有安装应该隐藏相关功能按钮

     // 同步方法
     var result = bmWXShare.isInstallWXApp()
  • 初始化友盟SDK initUM('appkey')

    在使用之前,请先调用此方法初始化友盟SDK

     bmWXShare.initUM('友盟平台申请的appkey')
  • 初始化微信SDK initWX(info)

    在使用分享到微信平台功能,或者微信登录功能前,需要调用此方法来初始化微信平台;

     bmWXShare.initWX({
       appKey: 'appkey', // 微信开发平台申请的appkey
       appSecret: 'appSecret', // appKey对应的appSecret,
       redirectURL: '回调页面' // 授权回调页面
     })
  • 分享:share(info,successCallback,failedCallback)

     bmWXShare.share({
       title:'', // 分享的标题
       content:'', // 分享的文字内容
       url: '', // 分享对应的URL地址,如h5、音乐链接、视频链接、小程序的链接
       image: '', // 分享的图片url
       path: '', // 分享小程序用到的页面路径
       shareType: 'Webpage', // 分享的类型
       platform: 'WechatSession' // 分享平台 朋友圈/好友(注意:历史版本的字段名是platforms,现在是一个字符串而不是数组)
     },function(resData){ // 注意: 历史版本返回的是一个promise对象,现在的是callback回调 	
       // 成功回调
     },function(resData){
       // 失败回调
     })
    
     // 分享平台
     platform:[
       WechatSession, // 微信好友
       WechatTimeLine // 分享至朋友圈
     ]
    
     // 分享类型
     shareType:[
       Text, // 文字
       Image, // 图片
       TextImage, // 图文
       Webpage, // 网页
       Music, // 音乐
       Video, // 视频
       MiniProgram // 小程序
     ]
  • 微信授权登录:authLogin(callback)

     bmWXShare.authLogin(function(resData){	
       // 授权结果,成功的话会将所有的userInfo返回
       // console.log(resData)
     });

Change Log

iOS 1.0.4
1.再次修复获取是否安装微信方法无效的问题;

iOS 1.0.3
1.修复获取是否安装微信方法无效的问题;

iOS 1.0.2
1.修复shareType字段取值问题;

iOS 1.0.1
1.修复友盟SDK报错的问题;

eros-plugin-ios-wxshare's People

Contributors

xiaohuapunk avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

eros-plugin-ios-wxshare's Issues

分享到小程序有点问题

怎么选择都会是网页类型,原因是BMShareModel里面的
NSString *type = dic[@"type"]; 应该为NSString *type = dic[@"shareType"];

然后还需要增加一个接收微信小程序userName的字段

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.