├── .github └── workflows │ └── ci.yml ├── .gitignore ├── README.md ├── android ├── README.md ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── uiwjs │ └── react │ └── wechat │ ├── RNWechatModule.java │ └── RNWechatPackage.java ├── example ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── App.js ├── __tests__ │ └── App-test.js ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── apple-app-site-association ├── babel.config.js ├── index.js ├── ios │ ├── Podfile │ ├── Podfile.lock │ ├── example-tvOS │ │ └── Info.plist │ ├── example-tvOSTests │ │ └── Info.plist │ ├── example.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── example-tvOS.xcscheme │ │ │ └── example.xcscheme │ ├── example.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── example │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ ├── example.entitlements │ │ └── main.m │ └── exampleTests │ │ ├── Info.plist │ │ └── exampleTests.m ├── metro.config.js ├── package.json └── yarn.lock ├── index.d.ts ├── index.js ├── ios ├── RNWechat.h ├── RNWechat.m ├── RNWechat.podspec ├── RNWechat.xcodeproj │ └── project.pbxproj └── RNWechat.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── package.json ├── renovate.json └── typedoc.json /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build and Deploy Documents 2 | on: 3 | push: 4 | branches: 5 | - master 6 | 7 | jobs: 8 | build-deploy: 9 | runs-on: ubuntu-18.04 10 | steps: 11 | - uses: actions/checkout@master 12 | 13 | - name: Setup Node 14 | uses: actions/setup-node@v1 15 | with: 16 | node-version: 10 17 | 18 | - run: npm install 19 | - run: npm run build 20 | - run: cp ./example/apple-app-site-association ./typedoc 21 | 22 | - name: Build and Deploy 23 | uses: peaceiris/actions-gh-pages@v2.5.0 24 | env: 25 | ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }} 26 | PUBLISH_BRANCH: gh-pages 27 | PUBLISH_DIR: ./typedoc 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # node.js 6 | # 7 | node_modules/ 8 | npm-debug.log 9 | yarn-error.log 10 | 11 | # Xcode 12 | # 13 | build/ 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | *.xccheckout 24 | *.moved-aside 25 | DerivedData 26 | *.hmap 27 | *.ipa 28 | *.xcuserstate 29 | project.xcworkspace 30 | 31 | # Android/IntelliJ 32 | # 33 | build/ 34 | .idea 35 | .gradle 36 | local.properties 37 | *.iml 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | 5 | 6 | 7 |

@uiw/react-native-wechat

8 |

9 | 10 | [![NPM Version](https://img.shields.io/npm/v/@uiw/react-native-wechat.svg)](https://npmjs.org/package/@uiw/react-native-wechat) 11 | ![David](https://img.shields.io/david/peer/uiwjs/react-native-alipay) 12 | 13 | React Native 包使用微信分享、登录、收藏、支付等功能,支持Android/iOS。完整实例 [Example](https://github.com/uiwjs/react-native-wechat/tree/master/example) | [完整的接口文档](https://uiwjs.github.io/react-native-alipay/) 14 | 15 | ## 注意事项 16 | 17 |

18 | iOS: 微信授权登录 Universal Link(通用链接) 19 | 20 | > [Universal Link(通用链接)](https://developer.apple.com/documentation/safariservices/supporting_associated_domains)是苹果在 iOS9 推出的,一种能够方便的通过传统 HTTPS 链接来启动 APP 的功能,可以使用相同的网址打开网址和 APP。 21 | > 看起来就是一条普通的 https 链接,当然是我们在该链接域名根目录配置过的一个链接,也可以在该链接中放置对应的H5页面。当用户的点击该链接,只要手机中安装了支持该链接的 APP 就会直接进入到 APP 中。如果没有安装APP则会跳转到 Safari 浏览器中,展示 H5 页面。对用户来说则是一个无缝跳转的过程。 22 | 23 | 创建一个名为 `apple-app-site-association` 的文件,如下: 24 | 25 | ```json 26 | { 27 | "applinks": { 28 | "details": [ 29 | { 30 | "appID": "968DSZ49MT.com.uiwjs.react.example.wechat", 31 | "paths": ["/react-native-wechat/*"] 32 | } 33 | ] 34 | } 35 | } 36 | ``` 37 | 38 | **说明:** 字段 appID 中的 `968DSZ49MT` 表示苹果账号的团队 `ID`,`com.uiwjs.react.example.wechat` 表示项目的 `BundleID`。 39 | 40 | ``` 41 | . 42 | ``` 43 | 44 | 上传该文件到你的域名所对应的`根目录`或`xxx目录`下,`apple-app-site-association` 文件不需要扩展名。 45 | 46 | **注意:** 苹果提供了一个[网页来验证](https://search.developer.apple.com/appsearch-validation-tool/)我们编写的这个 [apple-app-site-association](https://search.developer.apple.com/appsearch-validation-tool/) 是否合法有效。 47 | 48 | ``` 49 | https:///.well-known/apple-app-site-association 50 | 根目录 51 | https://uiwjs.github.io/apple-app-site-association 52 | 53 | xxx目录 54 | https://uiwjs.github.io/react-native-wechat/apple-app-site-association 55 | ``` 56 | 57 | 打开 `Associated Domains` 开关,将 [`Universal Links`](https://developer.apple.com/documentation/safariservices/supporting_associated_domains) 域名加到配置上,如果 `URL` 地址是 https://uiwjs.github.io/apple-app-site-association,那么, 58 | `Associated Domains` 中填写 `applinks: uiwjs.github.io`。 59 | 60 | 61 | 62 | 登录苹果开发者后台,在设置证书的页面找到 `Identifiers` 里,在对应的 `BundleId` 下勾选 `Associated Domains` 63 | 64 | 65 | 66 |
67 | 68 |
69 | iOS: -canOpenURL: failed for URL: "weixin://". 70 | 71 | > ``` 72 | > -canOpenURL: failed for URL: "weixin://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 73 | > ``` 74 | 75 | 设置 URL Schemes 并列为白名单,在 [`ios/<应用名称>/Info.plist`](https://github.com/uiwjs/react-native-wechat/blob/f6caea5b7d58dd05b7fc110ff76295c5e2be927b/example/ios/example/Info.plist#L23-L43) 中添加 76 | 77 | ```xml 78 | CFBundleURLTypes 79 | 80 | 81 | CFBundleURLName 82 | weixin 83 | CFBundleURLSchemes 84 | 85 | wx500b695a47bd364b 86 | 87 | 88 | 89 | LSApplicationQueriesSchemes 90 | 91 | weixin 92 | weixinULAPI 93 | 94 | ``` 95 | 96 |
97 | 98 |
99 | iOS: RCTBridge required dispatch_sync to load RCTDevLoadingView. 100 | 101 | > 错误内容: RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks 102 | 103 | **错误解决方案**:可以通过下面代码可以解决,事实上我通过关闭 debug 浏览器页面就没有错误消息了。错误原因可能是你打开了 debug 浏览器,但是你模拟器并没有开启 debug 模式。 104 | 105 | ```diff 106 | + #if RCT_DEV 107 | + #import 108 | + #endif 109 | 110 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 111 | { 112 | #ifdef FB_SONARKIT_ENABLED 113 | InitializeFlipper(application); 114 | #endif 115 | 116 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 117 | 118 | + #if RCT_DEV 119 | + [bridge moduleForClass:[RCTDevLoadingView class]]; 120 | + #endif 121 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"example" initialProperties:nil]; 122 | ``` 123 | 124 |
125 | 126 | ## 安装依赖 127 | 128 | ```bash 129 | yarn add @uiw/react-native-alipay 130 | # react-native version >= 0.60+ 131 | $ cd ios && pod install 132 | ``` 133 | 134 | ## 使用 135 | 136 | ```js 137 | import Wechat from '@uiw/react-native-wechat'; 138 | 139 | ``` 140 | 141 | ## 开发 142 | 143 | ```bash 144 | cd example # 进入实例 example 工程,根目录不需要安装,会引发错误 145 | yarn install # 安装依赖 146 | 147 | cd ios # 进入 example/ios 目录安装依赖 148 | pod instll # 安装依赖 149 | ``` 150 | 151 | ## 其它 152 | 153 | 当前工程基于 [@brodybits/create-react-native-module](https://github.com/brodybits/create-react-native-module) 初始化。 154 | 155 | ```bash 156 | npx create-react-native-module --package-identifier com.uiwjs.react.wechat --object-class-name RNWechat --generate-example Wechat --example-react-native-version 0.63.2 --module-name @uiw/react-native-wechat --github-account uiwjs --author-name "Kenny Wong" --author-email "wowohoo@qq.com" 157 | ``` 158 | 159 | ## 相关连接 160 | 161 | - [微信(SDK):iOS SDK v1.8.7.1](https://developers.weixin.qq.com/doc/oplatform/Downloads/iOS_Resource.html) 162 | - [微信(SDK):iOS 接入指南](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Access_Guide/iOS.html) 163 | - [@uiw/react-native-alipay](https://github.com/uiwjs/react-native-alipay) 支付宝支付。 164 | -------------------------------------------------------------------------------- /android/README.md: -------------------------------------------------------------------------------- 1 | README 2 | ====== 3 | 4 | If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: 5 | 6 | 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed 7 | 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK 8 | ``` 9 | ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle 10 | sdk.dir=/Users/{username}/Library/Android/sdk 11 | ``` 12 | 3. Delete the `maven` folder 13 | 4. Run `./gradlew installArchives` 14 | 5. Verify that latest set of generated files is in the maven folder with the correct version number 15 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // android/build.gradle 2 | 3 | // based on: 4 | // 5 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle 6 | // original location: 7 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle 8 | // 9 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle 10 | // original location: 11 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle 12 | 13 | def DEFAULT_COMPILE_SDK_VERSION = 28 14 | def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3' 15 | def DEFAULT_MIN_SDK_VERSION = 16 16 | def DEFAULT_TARGET_SDK_VERSION = 28 17 | 18 | def safeExtGet(prop, fallback) { 19 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 20 | } 21 | 22 | apply plugin: 'com.android.library' 23 | apply plugin: 'maven' 24 | 25 | buildscript { 26 | // The Android Gradle plugin is only required when opening the android folder stand-alone. 27 | // This avoids unnecessary downloads and potential conflicts when the library is included as a 28 | // module dependency in an application project. 29 | // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies 30 | if (project == rootProject) { 31 | repositories { 32 | google() 33 | jcenter() 34 | } 35 | dependencies { 36 | classpath 'com.android.tools.build:gradle:3.4.1' 37 | } 38 | } 39 | } 40 | 41 | apply plugin: 'com.android.library' 42 | apply plugin: 'maven' 43 | 44 | android { 45 | compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) 46 | buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) 47 | defaultConfig { 48 | minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) 49 | targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) 50 | versionCode 1 51 | versionName "1.0" 52 | } 53 | lintOptions { 54 | abortOnError false 55 | } 56 | } 57 | 58 | repositories { 59 | // ref: https://www.baeldung.com/maven-local-repository 60 | mavenLocal() 61 | maven { 62 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 63 | url "$rootDir/../node_modules/react-native/android" 64 | } 65 | maven { 66 | // Android JSC is installed from npm 67 | url "$rootDir/../node_modules/jsc-android/dist" 68 | } 69 | google() 70 | jcenter() 71 | } 72 | 73 | dependencies { 74 | //noinspection GradleDynamicVersion 75 | implementation 'com.facebook.react:react-native:+' // From node_modules 76 | // 微信SDK 77 | // Android Studio环境下:已改用gradle形式,发布到jcenter,请开发者使用gradle来编译、更新微信SDK。 78 | // 在build.gradle文件中,添加如下依赖即可: 79 | implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+' 80 | } 81 | 82 | def configureReactNativePom(def pom) { 83 | def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text) 84 | 85 | pom.project { 86 | name packageJson.title 87 | artifactId packageJson.name 88 | version = packageJson.version 89 | group = "com.uiwjs.react.wechat" 90 | description packageJson.description 91 | url packageJson.repository.baseUrl 92 | 93 | licenses { 94 | license { 95 | name packageJson.license 96 | url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename 97 | distribution 'repo' 98 | } 99 | } 100 | 101 | developers { 102 | developer { 103 | id packageJson.author.username 104 | name packageJson.author.name 105 | } 106 | } 107 | } 108 | } 109 | 110 | afterEvaluate { project -> 111 | // some Gradle build hooks ref: 112 | // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html 113 | task androidJavadoc(type: Javadoc) { 114 | source = android.sourceSets.main.java.srcDirs 115 | classpath += files(android.bootClasspath) 116 | classpath += files(project.getConfigurations().getByName('compile').asList()) 117 | include '**/*.java' 118 | } 119 | 120 | task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { 121 | classifier = 'javadoc' 122 | from androidJavadoc.destinationDir 123 | } 124 | 125 | task androidSourcesJar(type: Jar) { 126 | classifier = 'sources' 127 | from android.sourceSets.main.java.srcDirs 128 | include '**/*.java' 129 | } 130 | 131 | android.libraryVariants.all { variant -> 132 | def name = variant.name.capitalize() 133 | def javaCompileTask = variant.javaCompileProvider.get() 134 | 135 | task "jar${name}"(type: Jar, dependsOn: javaCompileTask) { 136 | from javaCompileTask.destinationDir 137 | } 138 | } 139 | 140 | artifacts { 141 | archives androidSourcesJar 142 | archives androidJavadocJar 143 | } 144 | 145 | task installArchives(type: Upload) { 146 | configuration = configurations.archives 147 | repositories.mavenDeployer { 148 | // Deploy to react-native-event-bridge/maven, ready to publish to npm 149 | repository url: "file://${projectDir}/../android/maven" 150 | configureReactNativePom pom 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/src/main/java/com/uiwjs/react/wechat/RNWechatModule.java: -------------------------------------------------------------------------------- 1 | package com.uiwjs.react.wechat; 2 | 3 | import com.facebook.react.bridge.ReactApplicationContext; 4 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 5 | import com.facebook.react.bridge.ReactMethod; 6 | import com.facebook.react.bridge.Callback; 7 | import com.facebook.react.bridge.Promise; 8 | import com.tencent.mm.opensdk.openapi.WXAPIFactory; 9 | import com.tencent.mm.opensdk.openapi.IWXAPI; 10 | 11 | public class RNWechatModule extends ReactContextBaseJavaModule { 12 | 13 | private final ReactApplicationContext reactContext; 14 | private String appId; 15 | private IWXAPI api = null; 16 | private final static String NOT_REGISTERED = "registerApp required."; 17 | 18 | public RNWechatModule(ReactApplicationContext reactContext) { 19 | super(reactContext); 20 | this.reactContext = reactContext; 21 | } 22 | 23 | @Override 24 | public String getName() { 25 | return "RNWechat"; 26 | } 27 | 28 | @ReactMethod 29 | public void registerApp(String appid, Promise promise) { 30 | try { 31 | this.appId = appid; 32 | api = WXAPIFactory.createWXAPI(reactContext.getApplicationContext(), null, false); 33 | promise.resolve(api.registerApp(appid)); 34 | } catch (Exception e) { 35 | promise.reject("-1", e.getMessage()); 36 | } 37 | } 38 | 39 | @ReactMethod 40 | public void getApiVersion(Promise promise) { 41 | try { 42 | if (api == null) { 43 | throw new Exception(NOT_REGISTERED); 44 | } 45 | promise.resolve(api.getWXAppSupportAPI()); 46 | } catch (Exception e) { 47 | promise.reject("-1", e.getMessage()); 48 | } 49 | } 50 | 51 | @ReactMethod 52 | public void openWXApp(Promise promise) { 53 | try { 54 | if (api == null) { 55 | throw new Exception(NOT_REGISTERED); 56 | } 57 | promise.resolve(api.openWXApp()); 58 | } catch (Exception e) { 59 | promise.reject("-1", e.getMessage()); 60 | } 61 | } 62 | 63 | @ReactMethod 64 | public void isWXAppInstalled(Promise promise) { 65 | try { 66 | if (api == null) { 67 | throw new Exception(NOT_REGISTERED); 68 | } 69 | promise.resolve(api.isWXAppInstalled()); 70 | } catch (Exception e) { 71 | promise.reject("-1", e.getMessage()); 72 | } 73 | } 74 | 75 | @ReactMethod 76 | public void isWXAppSupportApi(Promise promise) { 77 | try { 78 | if (api == null) { 79 | throw new Exception(NOT_REGISTERED); 80 | } 81 | int wxSdkVersion = api.getWXAppSupportAPI(); 82 | promise.resolve(wxSdkVersion); 83 | } catch (Exception e) { 84 | promise.reject("-1", e.getMessage()); 85 | } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /android/src/main/java/com/uiwjs/react/wechat/RNWechatPackage.java: -------------------------------------------------------------------------------- 1 | package com.uiwjs.react.wechat; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.bridge.NativeModule; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.uimanager.ViewManager; 11 | import com.facebook.react.bridge.JavaScriptModule; 12 | 13 | public class RNWechatPackage implements ReactPackage { 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | return Arrays.asList(new RNWechatModule(reactContext)); 17 | } 18 | 19 | @Override 20 | public List createViewManagers(ReactApplicationContext reactContext) { 21 | return Collections.emptyList(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; These should not be required directly 12 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 13 | node_modules/warning/.* 14 | 15 | ; Flow doesn't support platforms 16 | .*/Libraries/Utilities/LoadingView.js 17 | 18 | [untyped] 19 | .*/node_modules/@react-native-community/cli/.*/.* 20 | 21 | [include] 22 | 23 | [libs] 24 | node_modules/react-native/interface.js 25 | node_modules/react-native/flow/ 26 | 27 | [options] 28 | emoji=true 29 | 30 | esproposal.optional_chaining=enable 31 | esproposal.nullish_coalescing=enable 32 | 33 | module.file_ext=.js 34 | module.file_ext=.json 35 | module.file_ext=.ios.js 36 | 37 | munge_underscores=true 38 | 39 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 40 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 41 | 42 | suppress_type=$FlowIssue 43 | suppress_type=$FlowFixMe 44 | suppress_type=$FlowFixMeProps 45 | suppress_type=$FlowFixMeState 46 | 47 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 48 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 49 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 50 | 51 | [lints] 52 | sketchy-null-number=warn 53 | sketchy-null-mixed=warn 54 | sketchy-number=warn 55 | untyped-type-import=warn 56 | nonstrict-import=warn 57 | deprecated-type=warn 58 | unsafe-getters-setters=warn 59 | unnecessary-invariant=warn 60 | signature-verification-failure=warn 61 | deprecated-utility=error 62 | 63 | [strict] 64 | deprecated-type 65 | nonstrict-import 66 | sketchy-null 67 | unclear-type 68 | unsafe-getters-setters 69 | untyped-import 70 | untyped-type-import 71 | 72 | [version] 73 | ^0.122.0 74 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | }; 7 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Platform, Button, SafeAreaView, StyleSheet, Text, View } from 'react-native'; 3 | import Wechat from '@uiw/react-native-wechat'; 4 | 5 | export default class App extends Component { 6 | state = { 7 | isInstall: false, 8 | isWXAppSupportApi: false, 9 | version: null, 10 | }; 11 | async componentDidMount() { 12 | try { 13 | const reg = await Wechat.registerApp('wx500b695a47bd364b', 'https://uiwjs.github.io/react-native-wechat/apple-app-site-association'); 14 | const isInstall = await Wechat.isWXAppInstalled(); 15 | const isWXAppSupportApi = await Wechat.isWXAppSupportApi(); 16 | const version = await Wechat.getApiVersion(); 17 | console.log('version:', version); 18 | this.setState({ 19 | isInstall, 20 | isWXAppSupportApi, 21 | version 22 | }); 23 | } catch (error) { 24 | console.log('code>', error.code); 25 | console.log('message>', error.message); 26 | console.log('error>', error); 27 | } 28 | } 29 | openWXApp = async () => { 30 | const isOpen = await Wechat.openWXApp(); 31 | console.log('isOpen:', isOpen); 32 | } 33 | render() { 34 | const { isInstall, isWXAppSupportApi, version } = this.state; 35 | return ( 36 | 37 | 38 | ☆Wechat Example☆ 39 | 40 | 41 | {isInstall ? '已经' : '没有'}安装微信, 42 | 43 | 44 | 当前微信的版本{isWXAppSupportApi ? '支持' : '不支持'} OpenApi 45 | 46 | - v{version} 47 | 48 |