react-native-wechat-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.23 • Public • Published

react-native-wechat-ts (Android)

react native lib for wechat-pay wechat-oauth

react-native 微信支付-微信登录 lib

Intro

这个修改自react-native-wechat, 但已经完全重构了,依旧感谢前人的付出

更新了微信的 Android 版 SDK 为最新版

只支持安卓

implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+' 注意引入方式为最新版的意思

TODO

实现文字,图片分享

Installation

pnpm add react-native-wechat-ts

npm install react-native-wechat-ts

yarn add react-native-wechat-ts

Usage

import WechatTs from "react-native-wechat-ts";

//初始化SDK
WechatTs.registerApp('appid');

/* 检查手机是否安装微信 */
WechatTs.isWxAppInstalled(): boolean

/* 检查当前SDK版本 */
WechatTs.getApiVersion(): number

/* 打开微信app */
WechatTs.openWXApp(): boolean

WechatTs.pay({
  partnerId: string,
  prepayId: string,
  nonceStr: string,
  timeStamp: string,
  sign: string,
  packageValue: 'Sign=WXPay' // 固定值
}): object

/**
 * 微信授权登录
 * @deprecated
 * 由于SDK限制原因,接受不到回调,暂不可用
 **/
WechatTs.sendAuthRequest(): string

Notice

注意,微信 SDK 有几个大坑:

  1. 在 Android 11 的机子使用时需要修改android/src/AndroidManifest.xml,参考Android 11-第三方应用无法拉起微信适配
  2. 修改android/app/build.gradle配置,注意 debug 和 release 都换成真实环境下的,防止应用签名不对的问题
signingConfigs {
  debug {
    storeFile file('YOUR_UPLOAD_STORE_FILE')
    storePassword 'YOUR_STORE_PASSWORD'
    keyAlias 'YOUR_KEY_ALIAS'
    keyPassword 'YOUR_KEY_PASSWORD'
  }
  release {
    storeFile file('YOUR_UPLOAD_STORE_FILE')
    storePassword 'YOUR_STORE_PASSWORD'
    keyAlias 'YOUR_KEY_ALIAS'
    keyPassword 'YOUR_KEY_PASSWORD'
  }
}

License

MIT

Package Sidebar

Install

npm i react-native-wechat-ts

Weekly Downloads

0

Version

1.0.23

License

MIT

Unpacked Size

255 kB

Total Files

46

Last publish

Collaborators

  • a169kai