LocalNotification Plugin blank screen - ionic 4


#1

Hi everyone,
I tried to use the LocalNotifications Plugin from Ionic Native, but the app turnes out blank immediately after including the plugin. I know ionic 4 is in beta, so this may also be a bug…

This is my code (the module that includes the LocalNotification plugin):

import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { HomePage } from './home.page';
import { LocalNotifications } from '@ionic-native/local-notifications';

import { TeacherService } from '../Services/teacher.service';
import { StudentService } from '../Services/student.service';
import { LessonService } from '../Services/lesson.service';

@NgModule({
  imports: [
    IonicModule,
    CommonModule,
    FormsModule,
    RouterModule.forChild([{ path: '', component: HomePage }])
  ],
  declarations: [HomePage],
  providers: [
    TeacherService,
    StudentService,
    LessonService,
    LocalNotifications
  ]
})
export class HomePageModule {}

This is the error shown in the console both in the browser and on android:

Uncaught TypeError: Object(…) is not a function
at index.js:556
at Module…/node_modules/@ionic-native/local-notifications/index.js (index.js:796)
at webpack_require (bootstrap:83)
at Module…/src/app/app.module.ts (app.component.ts:11)
at webpack_require (bootstrap:83)
at Module…/src/main.ts (main.ts:1)
at webpack_require (bootstrap:83)
at Object.0 (main.ts:12)
at webpack_require (bootstrap:83)
at checkDeferredModules (bootstrap:45)

I’m in the following environment:
OS: Ubuntu 18.04.1 LTS
ionic-cli: 4.5.0
cordova: 8.1.0
node: 10.13.0
angular-cli: 6.2.6

Thank you very much in advance!


#2

Found out that i shouldn’t have installed the package
@ionic-native/local-notifications

but instead:
@ionic-native/local-notifications@beta

Also, there were little changes within the import. This was actually explained in the beta documents, looks like I was following the older version.