ionic-team / ionic-team/ionic-storage

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

Open
#282 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
456
Forks
97
PR merge metrics
No merged PRs in 30d

Description

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 ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.