Reputation: 11
I am a beginner in Ionic. Recently I am trying to use the Cordova local notifications plugin. By following the Ionic documentation at https://ionicframework.com/docs/native/local-notifications/ and the tutorial at https://www.joshmorony.com/getting-familiar-with-local-notifications-in-ionic-2, I was able to set up some notifications for my app. The plugin version is 0.9.0-beta.2.
However I ran into problem when I tried to set up repeating notifications. Not knowing what to do, I read the following documentation:
https://github.com/katzer/cordova-plugin-local-notifications/blob/master/README.md
Then I found that there are different ways to do the notification for my plugin version. In particular, the github document instructs the use of cordova.plugins.notification.local.schedule(...)
instead of this.localNotifications.schedule(...)
. This is confusing to me as a beginner as I don't know how to deal with this inconsistency. When I follow the new approach, it is said that cordova is not defined. I think this makes sense, but I cannot find any full example to show me how to get it work.
My questions:
I am eager to learn but it is sometimes frustrating to get stuck in documentations and tutorials only to find later that they are already outdated. Any general advice would also be appreciated.
Thank you in advance.
Upvotes: 0
Views: 644
Reputation: 604
For cordova is undefined error, you have to declare cordova as a variable in your typescript file as
declare var cordova;
before your class. After that you can use the cordova plugin as you are trying to use it.
Another approach will be to use this plugin as they have mentioned - https://ionicframework.com/docs/native/local-notifications/
Upvotes: 0