【问题标题】:Can I use a 3rd party React Native library within a cloud function?我可以在云函数中使用第 3 方 React Native 库吗?
【发布时间】:2022-02-11 06:52:26
【问题描述】:

我想做一些功能,让我的 Cloud Function 将它从 firestore 检索到的信息安全地存储到 react-native-keychain 中。我的问题是我可以将钥匙串库导入到我的函数文件夹中的 index.js 文件中以使用。 比如这样:

const keyChain = require("react-native-keychain");

这给了我这个错误:

【问题讨论】:

    标签: javascript node.js firebase react-native google-cloud-functions


    【解决方案1】:

    Cloud Functions 在 Google 的服务器上运行,没有可用的 React Native Keychain。

    如果您需要该库在您的 Cloud Functions 代码中提供的功能,则需要寻找在服务器端 Node.js 环境中提供该功能的其他库。

    如果您需要 React Native 应用程序内的钥匙串中的信息可用于 Cloud Function,您需要在您的 React Native 代码中读取它,并在调用时将其传递给 Cloud Function。

    【讨论】:

    • 我还认为,由于 Cloud Functions 的自毁性质,没有必要“存储”从 Firestore 获得的数据。另外,主要是你的代码在那里乱跑,所以你只能保护它不受自己的影响。
    猜你喜欢
    • 2018-08-13
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多