尝试了两种方式集成RN登录组件都报错

@authing/rn@2.1.1

Uncaught Error

TurboModuleRegistry.getEnforcing(…): ‘RNCWebView’ could not be found. Verify that a module by this name is registered in the native binary

另外,我们用的是ts环境,这个包没有ts类型定义,非常不方便。

之前有人提过,但不知道是不是同样的问题:React Native集成异常

@authing/guard-react18@5.3.1

Metro has encountered an error: While trying to resolve module @authing/guard-react18 from file /Desktop/MyApp/App.tsx, the package /Desktop/MyApp/node_modules/@authing/guard-react18/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Desktop/MyApp/node_modules/@authing/guard-react18/index. Indeed, none of these files exist:

  • /Desktop/MyApp/node_modules/@authing/guard-react18/index(.native|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  • /Desktop/MyApp/node_modules/@authing/guard-react18/index/index(.native|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx): /Desktop/MyApp/node_modules/metro/src/node-haste/DependencyGraph.js (289:17)

287 | }
288 | if (error instanceof InvalidPackageError) {

289 | throw new PackageResolutionError({
| ^
290 | packageError: error,
291 | originModulePath: from,
292 | targetModuleName: to,

RCTFatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start_sim
0x0

navigationRef.isReady(): true
WARN Possible Unhandled Promise Rejection (id: 0):
ReferenceError: Property ‘localStorage’ doesn’t exist
ReferenceError: Property ‘localStorage’ doesn’t exist
at anonymous (localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.ReactNativeDemo:243077:87)
at call (native)
at anonymous (localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.ReactNativeDemo:242775:27)
at anonymous (localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.ReactNativeDemo:242786:14)
at i (localhost:8081/index.bundle//&platform=ios&dev=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.ReactNativeDemo:242691:23)
at tryCallOne (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:53:16)
at anonymous (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:139:27)
at apply (native)

guard-react18 在您目前的场景中好像有两个问题 一个是工程向的 包无法解析 参考 react native - However, this package itself specifies a main module field that could not be resolved - Stack Overflow 还有一个是代码内 localStorage 不存在 这个我们看看

看的怎么样了,解决了吗

@authing/guard-react18@5.3.5-alpha.3

请使用该版本 并在初始化时 传入 storage

RN使用AsyncStorage作为本地存储,API都是异步的,您现在给出的storage使用方式是同步的吧?可能会有问题,您发我一个demo看看实际效果。

sdk 内部对 getitem 采用 await 兼容了异步 api

用@authing/rn这个包可以吗?看着是专用于RN的。