Giter Club home page Giter Club logo

native-wechat's Introduction

A React Native library for supporting Wechat APIs on Android and iOS

Native Wechatis released under the MIT license. Current npm package version.

For Expo Project

Please refer to Expo Native Wechat

Motivation

Most developers using React Native to build apps are not equipped with native developing skills, not to mention connecting their apps with WeChat.

Especially, WeChat OpenSDK is something pain in the ass because of shitty docs where lots of APIs are not clear and intuitive. To help developers using React Native, I tried as much as possible to create this library. And I hope you benefit from this and be less frustrated with WeChat.

Why

  • Native WeChat is new, and many libraries like it are no longer maintained and keep up with the latest WeChat.
  • Native WeChat supports both legacy and new React Native architecture.
  • Native WeChat is a TurboModule that supports lazy loading, allowing for faster app startup.
  • Supports TypeScript for better intellisense and easy-to-check typing errors.
  • All Apis are promisified.

Getting Started

Register SDK

Before invoking any APIs, registering Native WeChat by invoking registerApp is essential.

import {registerApp} from 'native-wechat';

useEffect(()=>{
	return registerApp('wx964290141ebe9b7b');
}, [])

When invoking registerApp, there will be a listener to receive events from Wechat. registerApp returns a function to remove the listener, and no events will be received from Wechat.

Invoking API

Now is the time to invoke API. For example, we will send an auth request to Wechat and receive the code. You may use the API named sendAuthRequest here.

import {registerApp, sendAuthRequest} from 'native-wechat';
import {Button, Text} from 'react-native';
import {verifyWechatCode} from '@/api/auth/wechat'

useEffect(()=>{
	registerApp('wx964290141ebe9b7b');
}, [])

const onButtonClicked = async () =>{
  const {data: {code}} = await sendAuthRequest();
  
  await verifyWechatCode(code);
}

return <Button onClick={onButtonClicked}>
  <Text>Send Auth Request</Text>
</Button>

Most APIs in Native WeChat are promisified. So is sendAuthRequest which will return a promise. When the user confirms the request on Wechat, the promise is resolved to be data with a code. All promisifed APIs return a generic type named NativeWechatResponse.

export type NativeWechatResponse<T = Record<string, unknown>> = {
  type: string;
  errorCode: number;
  errorStr: string | null;
  data: T;
};

Support

If you have trouble using this library, do not hesitate to open an issue. I am always here to help.

native-wechat's People

Contributors

hector-chong avatar l-7-l avatar lopo12123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

native-wechat's Issues

index.ts isWechatInstalled typo

index.ts
export const isWchatInstalled = () => { //isWchatInstalled missing an "e", should be isWechatInstalled
return promisifyNativeFunction(NativeModule.isWchatInstalled)(); //isWchatInstalled <== isWechatInstalled
};

Build failed after installed

image
I met this error after I installed this module on my project.
In code I actually just used registerApp('xxx') only.

And This app built successfully right after I remove this package.
Does anyone know why would this error occur?

在App.tsx中调用registerApp报错

useEffect(()=>{
registerApp({
appid: "wx964290141ebe9b7b"
});
}, [])
在App.tsx中调用registerApp报以下错误:
new NativeEventEmitter() was called with a non-null argument without the required addListener method.

使用RN0.74.3的版本 IOS集成不了

使用RN0.74.3的版本集成时,按照文档说明添加所有的配置后,安装后的app依旧不可用,调用的方法直接返回error 为undefined。并且去查看NativeModules的WeChat是空的undefined.

安卓上面正常使用,无问题

Android build failed

Hi, I was trying to run npx react-native run-android, but it failed. Could you help? Thank you so much.

BUILD FAILED in 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
G:\peaceful-channel-app\RN0710RC3\node_modules\native-wechat\android\src\main\java\com\hector\nativewechat\NativeWechatModuleImpl.java:94: error: cannot find symbol
wxApi = WXAPIFactory.createWXAPI(reactContext, id, true);
^
symbol: variable id
location: class NativeWechatModuleImpl
G:\peaceful-channel-app\RN0710RC3\node_modules\native-wechat\android\src\main\java\com\hector\nativewechat\NativeWechatModuleImpl.java:95: error: cannot find symbol
wxApi.registerApp(id);
^
symbol: variable id
location: class NativeWechatModuleImpl
Note: G:\peaceful-channel-app\RN0710RC3\node_modules\native-wechat\android\src\main\java\com\hector\nativewechat\NativeWechatModuleImpl.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':native-wechat:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.

  • What went wrong:
    java.lang.StackOverflowError (no error message)

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================

编译报错:':app:androidJdkImage' after task dependencies have been resolved

编译时遇到以下报错:

  • Where:
    Build file '...\node_modules\native-wechat\android\build.gradle' line: 63

  • What went wrong:
    A problem occurred evaluating project ':native-wechat'.

Cannot change resolution strategy of dependency configuration ':app:androidJdkImage' after task dependencies have been resolved


java version "17.0.7" 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)

应该和expo框架没有关系吧

shareWebpage 调用报错 catch err return undefined.

就是正常的流程,shareText 和其他的貌似都正常(可以唤起微信, 但是无法下一步,可能是因为app主体是海外,只能分享webpage以及小程序。) 但是webpage的调用就没有反应了,无法正常唤起微信而且api 进了catch。

await requestPayment(obj)没有返回支付信息

作者你好,requestPayment微信支付条转到微信支付完之后,点击返回app,没有返回支付信息,不论是try还是catch都没有返回结果。请问,这是什么情况,是我哪里配置有问题吗?

Android 版本 sendAuthRequest 请求无结果/无回调

参考文档接入遇到以下几个问题

1. gradle 构建脚本异常

构建时会因为 https://github.com/Hector-Chong/native-wechat/blob/main/android/build.gradle#L63 报错,

      force "com.facebook.react:react-native:0.70.+"
      force "com.facebook.react:hermes-engine:0.70.+"

注释后,可通过构建。

2. registerApp 注册应用 后输出 warn 日志

new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

3. sendAuthRequest 请求无结果/无回调

在业务应用中调用 sendAuthRequest ,能拉起微信,点击授权登录后,可以回到业务应用,但 sendAuthRequest 的 promise 既没有调用 then 也没有调用 catch。

从 Android Studio IDE 看日志,Android 系统已经调用了 业务应用包名.wxapi.WXEntryActivity indent 。

环境信息 设备真机 android 10,

"native-wechat": "^1.0.11",

npx react-native info

System:
  OS: Windows 10 10.0.22621
  CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  Memory: 5.14 GB / 15.67 GB
Binaries:
  Node:
    version: 18.16.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 8.6.0
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "30"
      - "33"
      - "33"
      - "33"
      - "34"
    Build Tools:
      - 29.0.0
      - 29.0.1
      - 29.0.2
      - 29.0.3
      - 30.0.2
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-29 | Google APIs Intel x86 Atom
      - android-31 | Google Play Intel x86_64 Atom
    Android NDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-223.8836.35.2231.10811636
  Visual Studio:
    - 15.9.28307.1622 (Visual Studio Community 2017)
Languages:
  Java:
    version: 20.0.2
    path: C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 11.3.9
    wanted: ^11.3.9
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.6
    wanted: ^0.72.6
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

只要能解决问题跑通逻辑,请有偿指导一下 :)

配置文档不适用 react-native 0.72.4

iOS 的 AppDelegate.mm 是这样的

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"<Your Project Name>";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

跟文档里不太一样,请问应该怎么配置呢?

react native to WeChat miniprogram

Hello, I saw this project called "native WeChat" and I understand it to be a tool that can convert programs built with the React Native framework into WeChat Mini Programs. I'm not sure if my understanding is correct.

Currently, I have a core business functionality developed using React Native, and I would like to convert it into WeChat Mini Program code and publish it on the Mini Program platform. Additionally, after using this tool to convert the code, I would still need to incorporate basic functionalities such as sharing, payment, user authentication, and user information retrieval using the existing WeChat APIs. Will this be affected?

I'm not very familiar with technical development, and I'm not proficient in using GitHub. I'm unsure where to ask these questions, so I apologize if I have posted in the wrong place. Thank you very much!

Android build failed

Hi, there are still errors on making an android build. I think you need to make these changes.

In NativeWechatModuleImpl.java, change all ids to appid

public void registerApp(ReadableMap request) {
appid = request.getString("appid");
registered = true;

wxApi = WXAPIFactory.createWXAPI(reactContext, appid, true); //<- here. change id to appid
wxApi.registerApp(appid);  //<- here. change id to appid

}

In index.ts

line 48: const nativeEmitter = new NativeEventEmitter(NativeModule)
Android throws a warning when new NativeEventEmitter() has param. warning is gone when change to these:
const nativeEmitter = Platform.OS === "ios" ?
new NativeEventEmitter(NativeModule) :
new NativeEventEmitter(); // For android, param is not needed.

Android Error in NativeWechatModuleImpl.java and NativeWechatModule

Hi, Hector
I found some problems。

NativeWechatModuleImpl.java

  public void registerApp(ReadableMap request) {
    appid = request.getString("appid");  
    registered = true;

    wxApi = WXAPIFactory.createWXAPI(reactContext, id, true);  //not id, id => appid
    wxApi.registerApp(id);  //not id, id => appid

NativeWechatModule.java

  public void registerApp(String id) { // not Stirng, Sting => ReadableMap ?
    moduleImpl.registerApp(id);
  }
  

在 reactnative 0.69.6 中似乎有冲突

我注意到您的包的devdependencies中的rn版本为 0.70.x,
image

我有一个现成的项目,它使用 expo (sdk 46) 构建。
我今天尝试加入了 native-wechat 这个包(仅仅是添加而没有任何使用),编译运行的时候就会报错
image

由于expo sdk指定要求的rn版本是0.69.6,所以我无法通过升级rn来解决冲突。

我不知道是不是native-wechat 这个包引入的版本冲突问题,请问你在 rn 0.69.x 中有测试过吗,

The library cannot be installed

Hi, thanks for the hard work. However, when I try to install your library, it throws me errors for both npm or yarn
npm ERR! code 1
npm ERR! path c:\my-app\node_modules\native-wechat
npm ERR! command failed
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is probably not a problem with npm.

关于ts支持和打包

我发现您的包并没有做打包处理,而是直接把文件放在了src目录下进行使用。
而且您在文档中描述有ts支持,但是实际使用并没有任何的ts支持(没有.d.ts 也没有在package.json 中指明 types 字段)

希望能添加打包和ts支持, 便于ide的自动提示功能, 谢谢

It just return undefined if wechat not installed

Is it possible to return a more specific message or error?

const res = await shareText({
text: 'text',
scene: NativeWechatConstants.WXSceneSession
}).catch(e=>{
  console.log(e) // e == undefined
})
// res == undefined

ps: there's a mistake in your demonstrate

import {registerApp} from 'native-wechat';

useEffect(()=>{
         // `registerApp` should accept a request-type argument
         // the blow code causes the crash, It makes me  almost give up
        // and the right way is registerApp({appId:'wx964290141ebe9b7b'})
	return registerApp('wx964290141ebe9b7b');
}, [])

Would you like to add some argument checks or catch errors in case of an app crash?

shareapi中的 shareWebpage 无法成功 (能唤起微信但点击好友无法进入下一步的分享)

以下是我的项目中的部分代码

    // 以下为我封装的抽象类 WXApi 中的网页分享的静态方法
    static async requestShareWebpage(webpageUrl: string, meta?: WXShareWebpageMeta, target: WXShareTarget = 'friend') {
        // 下一行仅为检查并确保已经执行 register
        WxOperates.prelude()

        try {
            await shareWebpage({ webpageUrl, scene: _wxShareTargetScene[target] })
            return true
        } catch (err) {
            return false
        }
    }


   // 另一个文件中调用
             WXApi.requestShareWebpage('https://hector.im', {
                  "title": 'test title',
                  "description": 'test description'
              })
              .then(res => {
                  console.log('res:', res)
              })
              .catch(err => {
                  console.log('err:', err)
              })

控制台仅会显示 res: true 字样,无报错信息但唤起微信后无法成功分享。

其他的分享api我都已经测试,能正常工作。

我的测试环境如下:

  • packages
    • "expo": "^47.0.0",
    • "react-native": "0.70.5",
    • "native-wechat": "^1.0.8",
  • device
    • 荣耀畅玩20 KOZ-AL00
    • android 10

first blood..

first blood..

great work. it seems to support newArch?

hope you save RN 3rd libs future(especially CN)

Expo Plugin Support

Hi,

Thanks for creating such new library for supporting WeChat.
However, A lot of new Expo projects are using managed workflow , which doesn't use prebuild to 'eject' the project so there is no way to modify the native codes. Expo-plugin is a feature to wrap all of those native changes so that projects with managed workflow don't have to modify the native codes.

Could you please consider adding such expo-plugin support to your project?
It will be a lot helpful for modern projects.

Thanks.

麻烦问下有详细的文档吗

作者你好,麻烦有详细的文档吗,按着readme的操作好像有报错

TypeError: Cannot read property 'registerApp' of undefined

Unknown type name 'WXOpenCustomerServiceReq'

按照您Web上的配置进行了修改 IOS端报错
image

这是我的.mm和.h文件 因为对IOS原声不熟悉 不知道是不是自己哪里配置错了
项目是React-Native 0.71.6
image
image
image
image
image
期待您的回复

Error when registering app

Somehow I can not register the app properly.
Here are the codes. (appid and universalLink is correct)

        // below applied in useEffect of App.js
        try {
            registerApp({
                appid: 'wx******14',
                universalLink: 'https://my.domain.com/*/',
                log: true
            })  
            checkUniversalLinkReady()
                .then(console.log)
                .catch(e => console.log(e))
        } catch (error) {
            console.log(error);
        }

Errors:

{
    "errorInfo": "appId or universalLink is nil", 
    "suggestion": "Please pass the correct parameters when calling the +[WXApi register:universalLink:] function"
}

My rewritten ios native code can refer the issue #21 I opened couple of days ago.

I'm a little confused right now, cuz I've got approved on Wechat, I've alse tested universal link and working properly now.

Is that I misunderstood the doc and implemented it in a wrong way? @Hector-Chong

请问下大佬,安装这个库之后ios无法启动,有如下报错

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_RCTBridge", referenced from:
objc-class-ref in AppDelegate.o
"OBJC_CLASS$_RCTBundleURLProvider", referenced from:
objc-class-ref in AppDelegate.o
"_RCTAppSetupDefaultRootView", referenced from:
-[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
"_RCTAppSetupPrepareApp", referenced from:
-[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

How to config IOS AppDelegate.mm in new Archetechture?

Since I am building with the new react native Archetechture. There is no AppDelegate.m file, but only an AppDelegate.mm file. Could you help me to config my AppDelegate.mm file? Thank you so much.

This is my AppDelegate.mm file

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>
#import <React/RCTConvert.h>

#import <React/RCTAppSetupUtils.h>

#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>

#import <react/config/ReactNativeConfig.h>

static NSString *const kRNConcurrentRoot = @"concurrentRoot";

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
  RCTTurboModuleManager *_turboModuleManager;
  RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
  std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
  facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTAppSetupPrepareApp(application);

  RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];

#if RCT_NEW_ARCH_ENABLED
  _contextContainer = std::make_shared<facebook::react::ContextContainer const>();
  _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
  _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
  _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
  bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif

  NSDictionary *initProps = [self prepareInitialProps];
  UIView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@"main" initialProperties:initProps];

  rootView.backgroundColor = [UIColor whiteColor];
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [self.reactDelegate createRootViewController];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  [super application:application didFinishLaunchingWithOptions:launchOptions];

  return YES;
}

- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
  // If you'd like to export some custom RCTBridgeModules, add them here!
  return @[];
}

/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
  // Switch this bool to turn on and off the concurrent root
  return true;
}

- (NSDictionary *)prepareInitialProps
{
  NSMutableDictionary *initProps = [NSMutableDictionary new];
#if RCT_NEW_ARCH_ENABLED
  initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
#endif
  return initProps;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
}

// Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
  return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  return [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
}

// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

#if RCT_NEW_ARCH_ENABLED

#pragma mark - RCTCxxBridgeDelegate

- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
  _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
                                                             delegate:self
                                                            jsInvoker:bridge.jsCallInvoker];
  return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}

#pragma mark RCTTurboModuleManagerDelegate

- (Class)getModuleClassFromName:(const char *)name
{
  return RCTCoreModulesClassProvider(name);
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                      jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
  return nullptr;
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
                                                     initParams:
                                                         (const facebook::react::ObjCTurboModule::InitParams &)params
{
  return nullptr;
}

- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
  return RCTAppSetupDefaultModuleFromClass(moduleClass);
}

#endif

@end

requestPayment arguments problem

Got this err when trying to request payment on android.

Error message: Wechat.requestPayment got 1 argument, expected 2

Here is what I found:
NativeWechatModuleImpl.java

  public void requestPayment(ReadableMap request, Callback callback) {  // <== 2 arguments
    PayReq payReq = new PayReq();

    payReq.partnerId = request.getString("partnerId");
    payReq.prepayId = request.getString("prepayId");
    payReq.nonceStr = request.getString("nonceStr");
    payReq.timeStamp = request.getString("timeStamp");
    payReq.sign = request.getString("sign");
    payReq.packageValue = request.getString("package");
    payReq.extData = request.getString("extData");
    payReq.appId = appid;

    callback.invoke(wxApi.sendReq(payReq) ? null : true);
  }

index.ts

export const requestPayment = (request: {  // <== only one argument
  partnerId: string;
  prepayId: string;
  nonceStr: string;
  timeStamp: string;
  sign: string;
}) => {
  assertRegisteration('requestPayment');

  NativeModule.requestPayment(request);

  return new Promise<NativeWechatResponse>((resolve, reject) => {
    notification.once('PayResp', (error, response) => {
      if (error) {
        return reject(error);
      }

      return resolve(response);
    });
  });
};

About maintance

Currently, this project is still under maintenance. However, I've been relocated and the integration of Wechat SDK is no longer my responsibility in my post. Therefore, my access to substantial information on WeChat development is forbidden, such as app ID, secret, domain, etc.

If you have any updates about WeChat SDK and the information mentioned above, please get in touch with me via my email on the GitHub profile page. I'd be happy to help with integrating and debugging the SDK and updating this library.


Actuellement, ce projet est toujours en cours de maintenance. Cependant, j'ai été réaffecté et l'intégration du kit de développement WeChat n'est plus de ma responsabilité dans mon poste actuel. Par conséquent, mon accès aux informations substantielles sur le développement WeChat est interdit, telles que l'application ID, le secret, le domaine, etc.

Si vous avez des mises à jour sur le kit de développement WeChat et les informations mentionnées ci-dessus, veuillez me contacter via mon adresse e-mail sur la page de profil GitHub. Je serais heureux de vous aider à intégrer et déboguer le SDK ainsi que de mettre à jour cette bibliothèque.


目前本项目仍处于维护状态。但是我已被转移到另一个岗位,微信 SDK 移植不再是我的职责。因此,我不再拥有调试与移植 SDK 的相关重要信息,例如 AppID、Secret、授权域名等。

若您知晓 WeChat SDK 出现了更新并且具有上述提及的信息,请联系我的 Github 主页邮箱,我将非常乐意为您移植、调试 SDK,并为此 Library 提供更新。

您好,安卓这边有个warning呢

WARN new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

还有我发现您的参数格式已经变了,但是文档没有更新。

Configurations of IOS AppDelegate have different situation with Expo been using

While configure ios project as described in doc, I found that the code is slightly different from what you present in section "Configuration".

Obviously, This will give some errors. I've tried to comment the original @interface .., still gives a lot of errors...

I also rewrite some code in comparison of code in doc and mine with AppDelegate.mm, not really helping. I have no idea of how to write native code, can you please have a look on this?

image

image

image

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.