-
Notifications
You must be signed in to change notification settings - Fork 97
Feat add flush method on Android #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e3566c6
to
fd78bdc
Compare
- to use flush method we need to set the min sdk to 21 because flush is added in sdk 21
fd78bdc
to
d27a4fb
Compare
69554a9
to
310a998
Compare
We call flush in varies methods, I'm assuming the motivation behind this PR is that there are cases where it did not call flush correctly. This begs the question should the methods manage calling flush themselves or the developer should always explicitly call flush? |
@safaiyeh I don't know what the motivation I only expose this method because this issue @perottilds can you explain why do you need to call this method? |
Sure, @luancurti Below a method I had to use to workaround the fact that I can't directly flush the cookies when my page first loads. import { LoginData } from '../observables/OnLoginObservable';
import RNCookieManager from '@react-native-community/cookies';
import AsyncStorage from '@react-native-community/async-storage';
import { config } from '../config';
const ACCESS_TOKEN_STORAGE_KEY = 'cookies.accessToken';
export class CookieManager {
static async handleLogin(_loginData: LoginData | null) {
const cookies = await RNCookieManager.get(config.DOMAIN);
if (!cookies || !cookies.accessToken) {
return;
}
await AsyncStorage.setItem(
ACCESS_TOKEN_STORAGE_KEY,
JSON.stringify(cookies.accessToken),
);
}
static async setAccessTokenFromStorage() {
const accessToken = await AsyncStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
if (!accessToken) {
return;
}
await RNCookieManager.set(config.DOMAIN, JSON.parse(accessToken));
}
} |
That makes sense @perottilds thanks! Appreciate the work on this @luancurti landing this. |
# [4.0.0](v3.0.3...v4.0.0) (2020-07-24) ### Features * **Android:** Add flush method on Android ([#64](#64)) ([74cd6a1](74cd6a1)) ### BREAKING CHANGES * **Android:** Android Minmum SDK bumped to API 21
🎉 This PR is included in version 4.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Add a method to flush cookies
Test Plan
Call the
CookieManager.flush
and the cookies should be flushedWhat's required for testing (prerequisites)?
What are the steps to reproduce (after prerequisites)?
Compatibility
Checklist
README.md
CHANGELOG.md
example/App.js
)