Latest update changed local notifications plugin?

After updating my node-modules to latest version, including ionic core etc. I got this error and I can’t seem to find anything about it? Some help please? Has anything changed to local notifications plugin or anything else that could get me this error?

[15:34:51] transpile started …
[15:35:10] typescript: D:/ionic/myApp1/src/pages/home/home.ts, line: 13
Expected 1 arguments, but got 2.

L12: this.platform.ready().then(() => {
L13: this.localNoti.on(‘click’, (noti, state) => {

L14: alert(state);

Error: Failed to transpile program
at new BuildError (D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\util
\errors.js:16:28)
at D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\transpile.js:159:20
at new Promise ()
at transpileWorker (D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\tra
nspile.js:107:12)
at Object.transpile (D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\tr
anspile.js:64:12)
at D:\ionic\myApp1\node_modules@ionic\app-scripts\dist\build.js:109:82
at

2 Likes

Yeah I experienced the same. As always the Ionic Docs are shitty and outdated.

The .on() function now returns an observable. So what you want to do is replace your code with this:

      this.localNotifications.on('click').subscribe(notification => {
        // Insert your logic here
      });
5 Likes

Wow man you saved my day!
Thank you so much for the fast reply!

1 Like

Hi @Hesters…i too got same error…then i use subscribe…but it shows run time error when notification function initiated…Even notification also don’t appears…any suggestion pls…

Sorry bro…faced with wrong code…got a solutions…thanks

I have the below piece of code, how can I modify it to work with subscribe. I tried changing a bit but did not work as it is used to. Thank you!


  constructor(public navCtrl: NavController, public alertController: AlertController, private plt: Platform, private localNotifications: LocalNotifications) {

    this.plt.ready().then((rdy)=>{
      this.localNotifications.on('click',(notification, state)=> {
        let json = JSON.parse(notification.data);

        let alert = this.alertController.create({
          title:notification.title,
          subTitle:json.mydata
        });
        alert.present(); 
      });
    });
  }

This is how you do it:

constructor(public navCtrl: NavController, public alertController: AlertController, private plt: Platform, private localNotifications: LocalNotifications) {

    this.plt.ready().then((rdy)=>{
      this.localNotifications.on('click').subscribe(notification => {
        let json = JSON.parse(notification.data);

        let alert = this.alertController.create({
          title:notification.title,
          subTitle:json.mydata
        });
        alert.present(); 
      });
    });
  }
2 Likes

I got this error Expected 2 arguments, but got 1.

and after 6 months ionic 3 reference guide still not updated and can’t demand as not from Pro. Is this the way open sources work?, struggling since few hrs on it. Thank you

Over a year later and those ‘quality’ Ionic Docs are still the bane of my existence. Thank you, Hesters, you are a god amongst men.