16 lines
432 B
TypeScript
16 lines
432 B
TypeScript
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
|
|
const TOKEN_KEY = 'cnapp.authToken';
|
|
|
|
export async function getStoredToken(): Promise<string | null> {
|
|
return AsyncStorage.getItem(TOKEN_KEY);
|
|
}
|
|
|
|
export async function setStoredToken(token: string | null): Promise<void> {
|
|
if (token === null) {
|
|
await AsyncStorage.removeItem(TOKEN_KEY);
|
|
} else {
|
|
await AsyncStorage.setItem(TOKEN_KEY, token);
|
|
}
|
|
}
|