gpt4 book ai didi

尝试从钥匙串(keychain)中获取保存的数据时,react-native-sensitive-info 给出 undefined

转载 作者:行者123 更新时间:2023-12-01 04:48:31 29 4
gpt4 key购买 nike

感谢这个伟大的图书馆。
我在我的一个 react-native 项目中使用这个库,但是每当我试图获取存储在 keychain 中的值时,都会在 iOS 中返回 undefined 。

Here is what is my use case
1-We have an existing "Native iOS App", which is already present in AppStore to download.
2-Now my client is redeveloping the same app in React-Native, and want to provide this new app as an update to existing users.
3-So we are keeping "Bundle ID" of our new (react-native app) same as that of older app (iOS native app), with higher version number ,so that our new will be downloaded as an updated.
4-Let's suppose, an existing user is already logged in the older app, so we want to maintain this logged status , whenever user update app with newer one.
5-In older app (iOS native app), we are saving "Access Token" in keychain, so based on whether "Access Token" is present in keychain, we decide the logged in status of user
6-Now, in newer app (react-native), we have to get that same "Access Token" from keychain, so that we can decide the logged in status of user and can navigate the user to appropriate screen.

I hope that makes sense!

Now when I am using this library, and try to get "Access Token" from keychain, its returning "undefined" in iOS.

Here may be I am doing something wrong, which only you guys can figure out.
This is how I am trying to get saved "Access Token".


SInfo.getItem("AccessToken", {}).then(value => {
alert(value);
console.log("access token is", value); // value1
});

最佳答案

我面临着类似的问题,我弄清楚发生了什么,我敢打赌我们在同一条船上。

我正在使用 react-native-sensitive-info为了存储 JWT,不是像您这样简单的 key ,而是来自 reducer (redux),因此路径是 authentication.jwt我期待按原样查询它,但它返回 undefined
经过一番调查,我发现 getItem的key,指的是你在配置store的时候给的key。

例如,我正在这样配置它:

const persistConfig = {
key: 'root',
transforms: [saveJwtOnly],
whitelist: ['authentication'],
storage
}
const persistedReducer = persistReducer(persistConfig, rootReducer)

关注 key: 'root' .现在, react-native-sensitive-info在它前面加上 persist:这样就我而言,唯一可用的 key 是 getItem就能返回是 persist:root ,它返回我存储的 authentication.jwt 的 JSON和 _persist包中的 key 。

关于尝试从钥匙串(keychain)中获取保存的数据时,react-native-sensitive-info 给出 undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44387984/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com