我想使用异步存储为我在 android 和 iOS 中的 react-native 应用程序存储一个 JSON 对象。我将对象字符串化并使用异步存储存储它,因为它只能存储字符串。该应用程序在 android 中运行良好,但在 iOS 中引发错误。错误如下:
Error: {
key = "";
message = "Invalid key - must be at least one character. Key: ";
}
RCTMakeAndLogError
RCTUtils.m:394
RCTErrorForKey
-[RCTAsyncLocalStorage _writeEntry:changedManifest:]
-[RCTAsyncLocalStorage multiSet:callback:]
__invoking___
-[NSInvocation invoke]
-[NSInvocation invokeWithTarget:]
-[RCTModuleMethod invokeWithBridge:module:arguments:]
facebook::react::RCTNativeModule::invokeInner(unsigned int, folly::dynamic const&&)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_queue_serial_drain
_dispatch_queue_invoke
_dispatch_queue_override_invoke
_dispatch_root_queue_drain
_dispatch_worker_thread3
_pthread_wqthread
start_wqthread
我的搜索使我在这里找到了用于 react-native 的异步存储的 iOS 实现,但我对 Objective-C 或 Swift 一无所知。如果有人可以在这里帮助我,将不胜感激。谢谢!
更新
我使用 AsyncStorage 将值存储在 JS 文件中。