0

I deployed a pwa version of my ionic 4 app. It works great but there is a problem with my app. If I add my app to my android home screen there is a small browser icon for example Chrome icon in the bottom right of my app icon. I saw this link:

How to Remove Chrome Logo from PWA App Home Screen Link (Android O Preview)

And then checked my application tab on google developers tools and I saw in the Manifest section the instability has a warning icon that show me this message: "No matching service worker detected. You may need to reload the page or check that the service worker for the current page also controls the start url from the manifest"

Even though there is my service worker in the folder, It seems that service worker not found by application!

Could you please help me to over come this issue?

UPDATE:

I found that this issue related to my lokijs database initialization. If I comment db initialization the service worker will be registered. I don't undrestand why this is happening. Is this mean that lokijs is not working with service worker?

for more info this is my db init inside lokijs service:

initDB = () => {
return new Observable((subs) => {
  const adapter = new LokiIndexedAdapter('roxanne', { closeAfterSave: true });
  this.db = new Loki('roxanne_db', {
    autosave: true,
    adapter: adapter
  });
  this.db.loadDatabase({}, (err) => {
    if (err) {
      console.log(err);
    } else {
      console.log('db was initialized');
      subs.next();
    }
  });
});

And I subscribe to this in my app.component.ts like this:

this.lokiService.initDB().subscribe(result => {
    console.log(result);
    // this.lokiService.checkDbCollections();
  }, err => console.log(err));

Is there a problem with my code or I have to consider another DB for my project?

Thanks

Hanif
  • 93
  • 1
  • 1
  • 9
  • how are you testing this? service workers have restrictions such as ssl (https) etc and making them work on just a local machine might need some tuning. Please share your setup. – Sergey Rudenko Mar 04 '20 at 16:18
  • As I said I'm working on Ionic4 project. So I just added angular service worker with "ng add @angular/pwa --project app" command and then created the production build with "ionic build --prod" command. And the for viewing my project I ran this command: "npx cap serve" and the app ran on localhost and port 3333. – Hanif Mar 07 '20 at 07:02

0 Answers0