Latest update changed local notifications plugin?


#1

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

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
      });

#3

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


#4

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…


#5

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


#6

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(); 
      });
    });
  }

#7

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(); 
      });
    });
  }

#8

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


#9

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