Encountering an issue with my ionic2 application where I save the last state in local storage when the app goes to the background. Upon resuming, it checks for the value of lastState in local storage and pushes that state if a value exists. The specific error being received is:
ERROR Error: Uncaught (in promise): invalid link: <StateName>
at c (file:///android_asset/www/build/polyfills.js:3:13190)
at Object.reject (file:///android_asset/www/build/polyfills.js:3:12546)
at NavControllerBase._fireError (file:///android_asset/www/build/main.js:44942:16)
at NavControllerBase._failed (file:///android_asset/www/build/main.js:44930:14)
at file:///android_asset/www/build/main.js:44985:59
at t.invoke (file:///android_asset/www/build/polyfills.js:3:8971)
at Object.onInvoke (file:///android_asset/www/build/main.js:4407:37)
at t.invoke (file:///android_asset/www/build/polyfills.js:3:8911)
at r.run (file:///android_asset/www/build/polyfills.js:3:4140)
at file:///android_asset/www/build/polyfills.js:3:13731
The application functions properly despite this error. Can someone shed light on the reason for this behavior?
Code app.component.ts
this.platform.pause.subscribe(() => {
console.log('[INFO] App Paused.');
localStorage.setItem("lastState", this.nav.last().name);
})
resume() method
this.platform.resume.subscribe(() => {
console.log('[INFO] App resumed);
if(null != localStorage.getItem("lastState") && localStorage.getItem("lastState") != undefined) {
this.nav.push(localStorage.getItem("lastState"));
}
});
Note: All component names have been added to app.module.ts