我在Android中运行Web应用程序.我可以缓存我的网页,所以如果用户没有网络连接,他仍然可以从缓存访问网页.但它仅在用户没有Internet连接时运行.
现在,为了优化我的应用程序,当用户有互联网连接时,我想要缓存所有显示的图像WebView并将其存储在本地/缓存它,当用户打开一个具有相同src图像的页面时,我已经缓存它,它从本地加载,不要再从网上加载它.或者可能不是图像,而是html访问缓存它的页面,当用户再次返回到url页面时,Webview从本地加载,而不是从Internet加载.
我已经搜索了两天的代码,但仍然找不到解决方案.
感谢帮助.
我通过本机反应并使用 rnfirebase 与 google firebase 身份验证连接来开发应用程序。我已经通过谷歌按钮登录代码,如下所示。
const _signIn = async () => {
setInitializing(true);
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
const credential = auth.GoogleAuthProvider.credential(
userInfo.idToken,
userInfo.accessToken,
);
return auth()
.signInWithCredential(credential)
.then(response => {
const uid = response.user.uid;
const data = {
uid: uid,
email: userInfo.user.email,
fullname: userInfo.user.name,
bio: 'I am ok ..',
username: uid.substring(0, 8),
};
const usersRef = firestore().collection('users');
usersRef
.doc(uid)
.get()
.then(firestoreDocument => {
if (!firestoreDocument.exists) {
usersRef
.doc(data.uid)
.set(data)
.then(() => {
RNRestart.Restart();
}) …Run Code Online (Sandbox Code Playgroud)