ionic-team / ionic-team/ionic-storage

IOS app doesn't retain state after ionic/storage version(3.0.6) upgrade for ionic app

Offen
#282 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
456
Forks
97
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hi team, I recently upgraded ionic storage from **V2.2.0** to **V3.0.6** in an ionic app. I'm facing IOS specific issue after the upgrade, IOS app doesn't retain login credentials after app kill which was retaining in **ionic/storage(2.2.0)** . Could you please help me to understand what I’m missing here ?

Code snippet after the upgrade:

```
import { IonicStorageModule } from '@ionic/storage-angular';
import { Drivers } from '@ionic/storage';
import * as CordovaSQLiteDriver from 'localforage-cordovasqlitedriver';
import { Storage } from '@ionic/storage-angular';

@NgModule({
imports: [
IonicStorageModule.forRoot({
driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB, Drivers.LocalStorage]
})
]})
```

**These are my env versions:**

```
Ionic CLI : 6.20.6
Ionic Framework : @ionic/angular 6.2.1
@angular-devkit/build-angular : 13.3.10
@angular-devkit/schematics : 13.3.10
@angular/cli : 13.1.2
@ionic/angular-toolkit : 6.1.0
@ionic/storage-angular : 3.0.6
@ionic/angular : 6.2.1
```

**Code Before upgrade**

```
getState(): Promise<{}> {
return this.storage.ready().then(() => {
return this.storage
.get(this.syncKey)
.then(s => s || {})
.catch(err => {
console.log(‘something wrong’)
return Promise.resolve({});
});
});
}


```

**Code after upgrade:**

```
getState(): Promise<{}> {
return this.storage.create().then(() => {
return this.storage
.get(this.syncKey)
.then(s => s || {})
.catch(err => {
console.log(‘something wrong’)
return Promise.resolve({});
});
});
}
```

**Important:** I’ve injected Storage service in multiple custom services, I replaced **this.storage.ready()** with **this.storage.create()** after the upgrade. Just curious to know if I’ve multiple occurrences of this.storage.ready() in a custom service and if I replace it with this.storage.create(), does it create a new instance every time getState() gets called ?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Reproduce the iOS persistence failure using the shown IonicStorageModule.forRoot driverOrder and getState() entry point after upgrading from 2.2.0 to 3.0.6. Compare the storage.create() lifecycle with the prior storage.ready() flow, and consider repeated calls from multiple injected services. Done means login state survives app termination and the storage instance lifecycle is understood.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.