【问题标题】:How to access data stored using cordova-plugin-secure-storage from a Reac Native app?如何从 React Native 应用程序访问使用 cordova-plugin-secure-storage 存储的数据?
【发布时间】:2020-05-25 01:00:48
【问题描述】:

我有一个基于 Cordova 的移动应用程序,其中一些数据使用 cordova-plugin-secure-storage 保存在设备上。例如:

var ss = new cordova.plugins.SecureStorage(
  function() {
    console.log("Success");
  },
  function(error) {
    console.log("Error " + error);
  },
  "my_namespace"
);

其中 my_namespace 表示插件使用的命名空间安全存储。

现在我必须编写这个移动应用程序的新版本,但使用 React Native 而不是 Ionic Cordova。问题是我仍然需要访问前一个应用程序的安全存储数据。有一些类似于cordova-plugin-secure-storage 的 React Native 插件可以让我访问命名空间的安全存储?

【问题讨论】:

    标签: react-native cordova ionic-framework storage


    【解决方案1】:

    您可以使用此模块 react-native-webkit-localstorage-reader 获取您的 web kit 本地存储

    但是您使用的模块似乎是在 android 上使用 sharedPreference 而在 iOS 上使用 keychain,因此您可能需要从这些地方获取数据。我的建议是在 react native 中使用与 cordova-plugin-secure-storage 相同的功能编写自己的本地模块。通过这种方式,如果您希望继续使用您的 react native 应用程序,您将能够使用相同的安全存储,如果不是在初始 react native 应用程序版本中,您可以将所有数据迁移到 React Native Async Storage

    制作原生模块的有用参考:

    Native Modules iOS

    Native Module android

    Creating a Native Module in React Native

    注意:您的数据已加密,因此您可能需要使用与之前模块相同的解密功能。​​

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      • 2022-12-07
      • 1970-01-01
      • 2018-02-22
      相关资源
      最近更新 更多