Search code examples
cordova-pluginsangular7ionic-nativeionic4

How do I set "skipLocalNotificationReady" for ionic-native plugin 'Local Notifications'


I need to set window.skipLocalNotificationReady = true but in an ionic 4 project.

I want to stop the local notification events until the device is ready. Therefore I need to set window.skipLocalNotificationReady = true, according to the plugin.

But in app.component.ts this doesn't work.I get the error, that 'skipLocalNotificationReady' is not part of 'Window'.

Itried cordovaPropertySet() but it tells me, that the plugin is not installed (it is).

constructor(
    private localNotifications: LocalNotifications,
) {
    //window.skipLocalNotificationReady = true

    cordovaPropertySet(
        this.localNotifications,
        'skipLocalNotificationReady', 
        true);

    this.initializeApp();
}

Is there any workaround or a possibility that cordovaPropertySet() will work?


Solution

  • enter image description here Yes! I have the same problem. After 20 times to try. I see that I call it too late. So I move that line sooner, before call app.component.ts. It is in main.ts.

    you can see the picture or view this:

    // main.ts
    import { enableProdMode } from '@angular/core';
    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    
    import { AppModule } from './app/app.module';
    import { environment } from './environments/environment';
    
    (<any>window).skipLocalNotificationReady = true;
    
    if (environment.production) {
      enableProdMode();
    }
    
    platformBrowserDynamic().bootstrapModule(AppModule)
      .catch(err => console.log(err));
    

    beside that. You must make sure that you have this function .fireQueuedEvents() because only cordova-plugin-local-notification@0.9.0-beta.3 have that feature:

    enter image description here