ionic-team / ionic-team/ionic-storage

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

Abierto
#282 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
456
Forks
97
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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 ?

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
mobile
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.