{"id":4734,"url":"https://github.com/yorkie/react-native-wechat","last_synced_at":"2025-09-27T07:32:35.912Z","repository":{"id":1765924,"uuid":"44363636","full_name":"yorkie/react-native-wechat","owner":"yorkie","description":"🚀 WeChat login, share, favorite and payment for React-Native on iOS and Android platforms (QQ: 336021910)","archived":true,"fork":false,"pushed_at":"2023-01-04T11:39:39.000Z","size":58389,"stargazers_count":2917,"open_issues_count":232,"forks_count":713,"subscribers_count":93,"default_branch":"master","last_synced_at":"2025-09-23T08:26:11.093Z","etag":null,"topics":["android","ios","js","mit","react-native","wechat","wechat-sdk"],"latest_commit_sha":null,"homepage":"https://npmjs.org/package/react-native-wechat","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/yorkie.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}},"created_at":"2015-10-16T05:12:31.000Z","updated_at":"2025-09-10T18:03:01.000Z","dependencies_parsed_at":"2023-01-13T11:45:22.283Z","dependency_job_id":null,"html_url":"https://github.com/yorkie/react-native-wechat","commit_stats":null,"previous_names":["weflex/react-native-wechat"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/yorkie/react-native-wechat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorkie%2Freact-native-wechat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorkie%2Freact-native-wechat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorkie%2Freact-native-wechat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorkie%2Freact-native-wechat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yorkie","download_url":"https://codeload.github.com/yorkie/react-native-wechat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yorkie%2Freact-native-wechat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277156207,"owners_count":25770567,"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","status":"online","status_checked_at":"2025-09-26T02:00:09.010Z","response_time":78,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["android","ios","js","mit","react-native","wechat","wechat-sdk"],"created_at":"2024-01-05T20:17:21.692Z","updated_at":"2025-09-27T07:32:30.904Z","avatar_url":"https://github.com/yorkie.png","language":"Objective-C","funding_links":[],"categories":["Components","Objective-C","目录"],"sub_categories":["Integrations"],"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.7.2\n- [x] Android SDK 221\n\n[react-native-wechat] has the following tracking data in the 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- [Getting Started](#getting-started)\n- [API Documentation](#api-documentation)\n- [Installation](#installation)\n- [Community](#community)\n- [Authors](#authors)\n- [License](#license)\n\n## Getting Started\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] uses Promises, therefore you can 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 the WeChat app is installed on the device.\n\n#### isWXAppSupportApi()\n\n- returns {Boolean} Contains the result.\n\nCheck if wechat support open url.\n\n#### getApiVersion()\n\n- returns {String} Contains the result.\n\nGet the WeChat SDK api version.\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- `title` {String}  title of this message. \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\nThe following examples require the 'react-native-chat' and 'react-native-fs' packages.\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 sends the message to a friend or chat group.\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## Partners\n\n[React Native Starter Kit](https://reactnativestarter.com/) - is a mobile starter kit that allows your team to fully focus on development of the features that set your product apart from the competitors instead of building your app from scratch.\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's using 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[@yorkie]: https://github.com/yorkie\n[@xing-zheng]: https://github.com/xing-zheng\n[@tdzl2003]: https://github.com/tdzl2003\n\n## License\n\nMIT\n\n[react-native-wechat]: https://github.com/yorkie/react-native-wechat\n[npm-image]: https://img.shields.io/npm/v/react-native-wechat.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/react-native-wechat\n[travis-image]: https://img.shields.io/travis/yorkie/react-native-wechat.svg?style=flat-square\n[travis-url]: https://travis-ci.org/yorkie/react-native-wechat\n[david-image]: http://img.shields.io/david/yorkie/react-native-wechat.svg?style=flat-square\n[david-url]: https://david-dm.org/yorkie/react-native-wechat\n[downloads-image]: http://img.shields.io/npm/dm/react-native-wechat.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/react-native-wechat\n[React Native]: https://github.com/facebook/react-native\n[react-native-cn]: https://github.com/reactnativecn\n[WeChat SDK]: https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list\u0026t=resource/res_list\u0026verify=1\u0026id=1417674108\u0026token=\u0026lang=zh_CN\n[Linking Libraries iOS Guidance]: https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/AddingaLibrarytoaTarget.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyorkie%2Freact-native-wechat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyorkie%2Freact-native-wechat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyorkie%2Freact-native-wechat/lists"}