imjayabal
imjayabal

Reputation: 819

Angular6 project has not detected new version deployment with service worker 6.1.10 version

I am working an Angular6 project with version detected popup with the service worker 6.1.10 it was working fine, but nowadays not working the version detected. I have placed below my code. I have tried some other ways to fix but no use. Please help me to fix this issue. Thanks in advance.

app.component.ts
----------------

if (this.swUpdate.isEnabled) {
      this.swUpdate.available.subscribe(() => {
        if (confirm('New version available. Load New Version?')) {
          window.location.reload();
        }
      });
    }

above code was working before but not working now, also I have tried some other way no use.

app.component.ts
----------------

updateClient() {
    if (!this.swUpdate.isEnabled) {
      console.log('Not Enabled');
      return;
    }
    this.swUpdate.available.subscribe((event) => {
      console.log('current', event.current, 'available ', event.available);
      if (confirm('Update available for the app please confom')) {
        this.swUpdate.activateUpdate().then(() => location.reload());
      }
    });
    this.swUpdate.activated.subscribe((event) => {
      console.log('current', event.previous, 'available ', event.current);
    });
  }

  checkUpdate() {
    this.appRef.isStable.subscribe((isStable) => {
      if (isStable) {
        const timeInterval = interval(6 * 60 * 60);

        timeInterval.subscribe(() => {
          this.swUpdate.checkForUpdate().then(() => console.log('checked'));
          console.log('update checked');
        });
      }
    });
  }

Upvotes: 0

Views: 38

Answers (0)

Related Questions