Skip to content
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

Storage gets cleared every other day (iOS) #1317

Closed
danielehrhardt opened this issue Nov 24, 2024 · 7 comments
Closed

Storage gets cleared every other day (iOS) #1317

danielehrhardt opened this issue Nov 24, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@danielehrhardt
Copy link

Bug report

https://forum.ionicframework.com/t/storage-gets-cleared-every-other-day-ios14/203254
The Supabase token are in the local storage the problem is that on Ionic Capacitor Apps the iOS Localstorage will be cleared every other day. This is why it need to be saved somewhere else. StorageDB for example.

@danielehrhardt danielehrhardt added the bug Something isn't working label Nov 24, 2024
@kewur
Copy link

kewur commented Dec 6, 2024

I have the same issue with angular 18. I am using a custom storage, but storage works fine for one day. the next day, on the first load the stored key isnt accessed (says last accessed the day before) and on page refresh the stored key gets deleted altogether.

@danielehrhardt
Copy link
Author

I have the same issue with angular 18. I am using a custom storage, but storage works fine for one day. the next day, on the first load the stored key isnt accessed (says last accessed the day before) and on page refresh the stored key gets deleted altogether.


 const customStorage = {
      getItem: (key: string) => this.storage.get(key),
      setItem: (key: string, value: string) => this.storage.set(key, value),
      removeItem: (key: string) => this.storage.remove(key),
    };

    this.supabase = createClient(environment.supabaseUrl, environment.supabaseKey, {
      auth: {
        storage: customStorage,
      },
    });

@kewur
Copy link

kewur commented Dec 6, 2024

doesnt work with angular. I'll create a new ticket then, thanks for the reply anyway

@danielehrhardt
Copy link
Author

doesnt work with angular. I'll create a new ticket then, thanks for the reply anyway

The Code is from a angular app

@kewur
Copy link

kewur commented Dec 6, 2024

cant use this.storage since that doesnt work with ssr.

@danielehrhardt
Copy link
Author

cant use this.storage since that doesnt work with ssr.

you need to add your own indexdb logic

@kewur
Copy link

kewur commented Dec 6, 2024

already have that, issue persists.

this is the implementation that we use. SsrCookiService is coming from the package ngx-cookie-service-ssr

import { Inject, Injectable } from '@angular/core';
import { SsrCookieService } from 'ngx-cookie-service-ssr';
import { SupportedStorage } from '@supabase/supabase-js';

@Injectable({
  providedIn: 'root',
})
export class SupabaseStorageService implements SupportedStorage {
  constructor(
    private readonly cookieService: SsrCookieService,
  ) {
  }

  getItem(key: string): string | Promise<string | null> | null {
    return this.cookieService.get(key);
  }

  setItem(key: string, value: string): void | Promise<void> {
    this.cookieService.set(key, value);
  }

  removeItem(key: string): void | Promise<void> {
    this.cookieService.delete(key);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants