{"id":22941818,"url":"https://github.com/zacksleo/react-native-wechat-share","last_synced_at":"2025-04-01T21:17:35.332Z","repository":{"id":75725033,"uuid":"173958252","full_name":"zacksleo/react-native-wechat-share","owner":"zacksleo","description":"react-native-wechat without pay","archived":false,"fork":false,"pushed_at":"2019-03-05T14:15:54.000Z","size":6595,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-07T13:47:45.593Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","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/zacksleo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-05T14:07:28.000Z","updated_at":"2019-03-05T14:15:56.000Z","dependencies_parsed_at":"2023-06-19T13:08:02.332Z","dependency_job_id":null,"html_url":"https://github.com/zacksleo/react-native-wechat-share","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksleo%2Freact-native-wechat-share","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksleo%2Freact-native-wechat-share/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksleo%2Freact-native-wechat-share/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacksleo%2Freact-native-wechat-share/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zacksleo","download_url":"https://codeload.github.com/zacksleo/react-native-wechat-share/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246709913,"owners_count":20821298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-14T13:45:07.128Z","updated_at":"2025-04-01T21:17:35.316Z","avatar_url":"https://github.com/zacksleo.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg height=\"200\" src=\"./weixin.png?raw=true\"\u003e\n\n# React-Native-Wechat\n\n[React Native] bridging library that integrates WeChat SDKs:\n\n- [x]  iOS SDK 1.8.2\n- [x]  Android SDK ++\n\nAnd [react-native-wechat] has the following tracking data in open source world:\n\n| NPM                                  | Dependency                                     | Downloads                                      | Build                                       |\n| ------------------------------------ | ---------------------------------------------- | ---------------------------------------------- | ------------------------------------------- |\n| [![NPM version][npm-image]][npm-url] | [![Dependency Status][david-image]][david-url] | [![Downloads][downloads-image]][downloads-url] | [![Build Status][travis-image]][travis-url] |\n\n## Table of Contents\n\n- [Get Startted](#get-startted)\n- [API Documentation](#api-documentation)\n- [Installation](#installation)\n- [Community](#community)\n- [Authors](#authors)\n- [License](#license)\n\n## Get Startted\n\n- [Build setup on iOS](./docs/build-setup-ios.md)\n- [Build setup on Android](./docs/build-setup-android.md)\n\n## API Documentation\n\n[react-native-wechat] exposes the promise-based, therefore you could use `Promise`\nor `async/await` to manage your dataflow.\n\n#### registerApp(appid)\n\n- `appid` {String} the appid you get from WeChat dashboard\n- returns {Boolean} explains if your application is registered done\n\nThis method should be called once globally.\n\n```js\nimport * as WeChat from 'react-native-wechat';\n\nWeChat.registerApp('appid');\n```\n\n#### registerAppWithDescription(appid, description)\n\n- `appid` {String} the appid you get from WeChat dashboard\n- `description` {String} the description of your app\n- returns {Boolean} explains if your application is registered done\n\nThis method is only available on iOS.\n\n#### isWXAppInstalled()\n\n- returns {Boolean} if WeChat is installed.\n\nCheck if wechat installed in this app.\n\n#### isWXAppSupportApi() (iOS平台)\n\n- returns {Boolean}  Contain the result.\n\nCheck if wechat support open url.\n#### isWXAppSupportApi(supportSdk) (Android平台)\n```java\n    //传入对应的字符串判断是否支持,没有找到微信文档,字面意思自己理解\n    public static final int SDK_INT = 620824064;\n    public static final int MIN_SDK_INT = 553713665;\n    public static final int CHECK_TOKEN_SDK_INT = 620824064;\n    public static final int TIMELINE_SUPPORTED_SDK_INT = 553779201;\n    public static final int EMOJI_SUPPORTED_SDK_INT = 553844737;\n    public static final int MUSIC_DATA_URL_SUPPORTED_SDK_INT = 553910273;\n    public static final int PAY_SUPPORTED_SDK_INT = 570425345;\n    public static final int OPENID_SUPPORTED_SDK_INT = 570425345;\n    public static final int FAVORITE_SUPPPORTED_SDK_INT = 570425345;\n    public static final int MESSAGE_ACTION_SUPPPORTED_SDK_INT = 570490883;\n    public static final int SCAN_QRCODE_AUTH_SUPPORTED_SDK_INT = 587268097;\n    public static final int MINIPROGRAM_SUPPORTED_SDK_INT = 620756993;\n    public static final int VIDEO_FILE_SUPPORTED_SDK_INT = 620756996;\n    public static final int SUBSCRIBE_MESSAGE_SUPPORTED_SDK_INT = 620756998;\n    public static final int LAUNCH_MINIPROGRAM_SUPPORTED_SDK_INT = 620757000;\n    public static final int CHOOSE_INVOICE_TILE_SUPPORT_SDK_INT = 620822528;\n    public static final int INVOICE_AUTH_INSERT_SDK_INT = 620823552;\n    public static final int NON_TAX_PAY_SDK_INT = 620823552;\n    public static final int PAY_INSURANCE_SDK_INT = 620823552;\n    public static final int SUBSCRIBE_MINI_PROGRAM_MSG_SUPPORTED_SDK_INT = 620823808;\n    public static final int OFFLINE_PAY_SDK_INT = 620823808;\n    public static final int SEND_TO_SPECIFIED_CONTACT_SDK_INT = 620824064;\n    public static final int OPEN_BUSINESS_WEBVIEW_SDK_INT = 620824064;\n```\n- returns {Boolean}  Contain the result.\n\nCheck if wechat support open url.\n\n#### getApiVersion()\n\n- returns {String}  Contain the result.\n\nGet api version of WeChat SDK.\n\n#### openWXApp()\n\n- returns {Boolean} \n\nOpen the WeChat app from your application.\n\n#### sendAuthRequest([scope[, state]])\n\n- `scope` {Array|String} Scopes of auth request.\n- `state` {String} the state of OAuth2\n- returns {Object}\n\nSend authentication request, and it returns an object with the \nfollowing fields:\n\n| field   | type   | description                         |\n| ------- | ------ | ----------------------------------- |\n| errCode | Number | Error Code                          |\n| errStr  | String | Error message if any error occurred |\n| openId  | String |                                     |\n| code    | String | Authorization code                  |\n| url     | String | The URL string                      |\n| lang    | String | The user language                   |\n| country | String | The user country                    |\n\n#### class `ShareMetadata`\n\n- `type` {Number} type of this message. Can be {news|text|imageUrl|imageFile|imageResource|video|audio|file}\n- `thumbImage` {String} Thumb image of the message, which can be a uri or a resource id.\n- `description` {String} The description about the sharing.\n- `webpageUrl` {String} Required if type equals `news`. The webpage link to share.\n- `imageUrl` {String} Provide a remote image if type equals `image`.\n- `videoUrl` {String} Provide a remote video if type equals `video`.\n- `musicUrl` {String} Provide a remote music if type equals `audio`.\n- `filePath` {String} Provide a local file if type equals `file`.\n- `fileExtension` {String} Provide the file type if type equals `file`.\n\n#### shareToTimeline(message)\n\n- `message` {ShareMetadata} This object saves the metadata for sharing\n- returns {Object}\n\nShare a `ShareMetadata` message to timeline(朋友圈) and returns:\n\n| name    | type   | description                         |\n| ------- | ------ | ----------------------------------- |\n| errCode | Number | 0 if authorization successed        |\n| errStr  | String | Error message if any error occurred |\n\nThese example code need 'react-native-chat' and 'react-native-fs' plugin.\n\n```js\nimport * as WeChat from 'react-native-wechat';\nimport fs from 'react-native-fs';\nlet resolveAssetSource = require('resolveAssetSource');\n\n// Code example to share text message:\ntry {\n  let result = await WeChat.shareToTimeline({\n    type: 'text', \n    description: 'hello, wechat'\n  });\n  console.log('share text message to time line successful:', result);\n} catch (e) {\n  if (e instanceof WeChat.WechatError) {\n    console.error(e.stack);\n  } else {\n    throw e;\n  }\n}\n\n// Code example to share image url:\n// Share raw http(s) image from web will always fail with unknown reason, please use image file or image resource instead\ntry {\n  let result = await WeChat.shareToTimeline({\n    type: 'imageUrl',\n    title: 'web image',\n    description: 'share web image to time line',\n    mediaTagName: 'email signature',\n    messageAction: undefined,\n    messageExt: undefined,\n    imageUrl: 'http://www.ncloud.hk/email-signature-262x100.png'\n  });\n  console.log('share image url to time line successful:', result);\n} catch (e) {\n  if (e instanceof WeChat.WechatError) {\n    console.error(e.stack);\n  } else {\n    throw e;\n  }\n}\n\n// Code example to share image file:\ntry {\n  let rootPath = fs.DocumentDirectoryPath;\n  let savePath = rootPath + '/email-signature-262x100.png';\n  console.log(savePath);\n\n  /*\n   * savePath on iOS may be:\n   *  /var/mobile/Containers/Data/Application/B1308E13-35F1-41AB-A20D-3117BE8EE8FE/Documents/email-signature-262x100.png\n   *\n   * savePath on Android may be:\n   *  /data/data/com.wechatsample/files/email-signature-262x100.png\n   **/\n  await fs.downloadFile('http://www.ncloud.hk/email-signature-262x100.png', savePath);\n  let result = await WeChat.shareToTimeline({\n    type: 'imageFile',\n    title: 'image file download from network',\n    description: 'share image file to time line',\n    mediaTagName: 'email signature',\n    messageAction: undefined,\n    messageExt: undefined,\n    imageUrl: \"file://\" + savePath // require the prefix on both iOS and Android platform\n  });\n  console.log('share image file to time line successful:', result);\n} catch (e) {\n  if (e instanceof WeChat.WechatError) {\n    console.error(e.stack);\n  } else {\n    throw e;\n  }\n}\n\n// Code example to share image resource:\ntry {\n  let imageResource = require('./email-signature-262x100.png');\n  let result = await WeChat.shareToTimeline({\n    type: 'imageResource',\n    title: 'resource image',\n    description: 'share resource image to time line',\n    mediaTagName: 'email signature',\n    messageAction: undefined,\n    messageExt: undefined,\n    imageUrl: resolveAssetSource(imageResource).uri\n  });\n  console.log('share resource image to time line successful', result);\n}\ncatch (e) {\n  if (e instanceof WeChat.WechatError) {\n    console.error(e.stack);\n  } else {\n    throw e;\n  }\n}\n\n// Code example to download an word file from web, then share it to WeChat session\n// only support to share to session but time line\n// iOS code use DocumentDirectoryPath\ntry {\n  let rootPath = fs.DocumentDirectoryPath;\n  let fileName = 'signature_method.doc';\n  /*\n   * savePath on iOS may be:\n   *  /var/mobile/Containers/Data/Application/B1308E13-35F1-41AB-A20D-3117BE8EE8FE/Documents/signature_method.doc\n   **/ \n  let savePath = rootPath + '/' + fileName;\n\n  await fs.downloadFile('https://open.weixin.qq.com/zh_CN/htmledition/res/assets/signature_method.doc', savePath);\n  let result = await WeChat.shareToSession({\n    type: 'file',\n    title: fileName, // WeChat app treat title as file name\n    description: 'share word file to chat session',\n    mediaTagName: 'word file',\n    messageAction: undefined,\n    messageExt: undefined,\n    filePath: savePath,\n    fileExtension: '.doc'\n  });\n  console.log('share word file to chat session successful', result);\n} catch (e) {\n  if (e instanceof WeChat.WechatError) {\n    console.error(e.stack);\n  } else {\n    throw e;\n  }\n}\n\n//android code use ExternalDirectoryPath\ntry {\n  let rootPath = fs.ExternalDirectoryPath;\n  let fileName = 'signature_method.doc';\n  /*\n   * savePath on Android may be:\n   *  /storage/emulated/0/Android/data/com.wechatsample/files/signature_method.doc\n   **/\n  let savePath = rootPath + '/' + fileName;\n  await fs.downloadFile('https://open.weixin.qq.com/zh_CN/htmledition/res/assets/signature_method.doc', savePath);\n  let result = await WeChat.shareToSession({\n    type: 'file',\n    title: fileName, // WeChat app treat title as file name\n    description: 'share word file to chat session',\n    mediaTagName: 'word file',\n    messageAction: undefined,\n    messageExt: undefined,\n    filePath: savePath,\n    fileExtension: '.doc'\n  });\n  console.log('share word file to chat session successful', result);\n}\ncatch (e) {\n  if (e instanceof WeChat.WechatError) {\n    console.error(e.stack);\n  } else {\n    throw e;\n  }\n}\n```\n\n#### shareToSession(message)\n\n- `message` {ShareMetadata} This object saves the metadata for sharing\n- returns {Object}\n\nSimilar to `shareToTimeline` but send message to a friend or chat group.\n\n#### launchMini(params)\n\n- `params` {Object} 打开小程序的参数\n\n  - `userName` {String} 拉起的小程序的username\n\n  - `miniProgramType` {Integer} 拉起小程序的类型. 0-正式版 1-开发版 2-体验版\n\n  - `path` {String} 拉起小程序页面的可带参路径，不填默认拉起小程序首页\n\n    \n\n#### pay(payload)\n\n- `payload` {Object} the payment data\n  - `partnerId` {String} 商家向财付通申请的商家ID\n  - `prepayId` {String} 预支付订单ID\n  - `nonceStr` {String} 随机串\n  - `timeStamp` {String} 时间戳\n  - `package` {String} 商家根据财付通文档填写的数据和签名\n  - `sign` {String} 商家根据微信开放平台文档对数据做的签名\n- returns {Object}\n\nSends request for proceeding payment, then returns an object:\n\n| name    | type   | description                         |\n| ------- | ------ | ----------------------------------- |\n| errCode | Number | 0 if authorization successed        |\n| errStr  | String | Error message if any error occurred |\n\n## Installation\n\n```sh\n$ npm install react-native-wechat --save\n```\n\n## Community\n\n#### IRC\n\n\u003ca href=\"http://qm.qq.com/cgi-bin/qm/qr?k=cg3irEFCGxjkm2YJCt5V9OeJA1pNo5Ui\"\u003e\u003cimg width=\"200\" src=\"./qrcode_qq.jpg\"\u003e\u003c/a\u003e\n\n#### Tutorials\n\n- [react-native-wechat微信组件的使用](http://www.jianshu.com/p/3f424cccb888)\n- [超详细React Native实现微信好友/朋友圈分享功能-Android/iOS双平台通用](http://www.jianshu.com/p/ce5439dd1f52)\n- [柳轩涤俗 - 微信登录](http://www.cnblogs.com/zhangdw/p/6194345.html)\n\n#### Who use it\n\n\u003ca href=\"https://github.com/attentiveness/reading\"\u003e\u003cimg height=\"80\" width=\"80\" src=\"https://raw.githubusercontent.com/attentiveness/reading/master/Reading_Logo.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/lipeiwei-szu/ReactNativeOne\"\u003e\u003cimg height=\"80\" width=\"80\" src=\"http://android-artworks.25pp.com/fs08/2017/05/22/3/110_ed42e5c8f701ae26be6b0c423cb51858_con_130x130.png\"\u003e\u003c/a\u003e\n\n## Authors\n\n| GitHub        | Role    | Email                 |\n| ------------- | ------- | --------------------- |\n| [@yorkie]     | Author  | yorkiefixer@gmail.com |\n| [@xing-zheng] | Emeriti |                       |\n| [@tdzl2003]   | Emeriti | tdzl2003@gmail.com    |\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacksleo%2Freact-native-wechat-share","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzacksleo%2Freact-native-wechat-share","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacksleo%2Freact-native-wechat-share/lists"}