Trigger argument doesnt recognized
See original GitHub issueWARNING: IF YOU IGNORE THIS TEMPLATE, WE’LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!
Provide a general summary of the issue.
Your Environment
- Plugin version: 0.9.0-beta.1
- Platform:Android
- OS version: ^6.4.0
- Device manufacturer / model:
- Cordova version (
cordova -v
): 7.1.0 - Cordova platform version (
cordova platform ls
): Android 6.4.0 - Plugin config
- Ionic Version (if using Ionic): 3.19.0
Expected Behavior
I wanna receive repeating notifications with my ionic app, passing a value in minutes
Actual Behavior
Nothing happens
Steps to Reproduce
Reproduce this issue; include code to reproduce, if relevant
- Import a Local Notification on a Ionic Page “import { LocalNotifications } from ‘@ionic-native/local-notifications’;”
- Put o construct: private localNotifications: LocalNotifications,
- Schedule a new notification with this code: as related on documentation this.localNotifications.schedule({ id: 1, icon: ‘res/iconred.png’, title: ‘Hora de tomar água!’, trigger: {every: ‘day’, count: 300} });
- The code doest work
Context
First of all… I wanna do a repeating notification. Ive read the entire documentation, but when I wanna put the “trigger” option on the schedule function I receive the following error: “Argument of type ‘{ id: number; icon: string; title: string; trigger: { every: string; count: number; }; }’ is not assignable to parameter of type ‘ILocalNotification | ILocalNotification[]’. Object literal may only specify known properties, and ‘trigger’ does not exist in type ‘ILocalNotification | ILocalNotification[]’.”
Searching the files I found this interface “ILocalNotification” who make part of the native local notification and really, it doesnt have this argument. I tried to reinstall the plugin but nothing happens too. I dont know if its diferent (the native one, imported with @ionic-native/local-notifications) from the Katzer plugin.
If i change the “trigger” option with “every: ‘minute’”, I only receive one notification too.
Debug logs
Include iOS / Android logs
- ios XCode logs
- Android: $ adb logcat
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (1 by maintainers)
Top GitHub Comments
I have found a solution that seems to work at least for now: use the cordova plugin directly (in the ionic project), instead of the ionic native version, which is not updated. It would still be nice for the ionic native version to be updated, but the below seems to work for now.
Some tips on how to use the cordova plugin instead of the ionic native version are here:
The following steps allowed me to have the cordova plugin version work in the ionic app. Note, it would work in the emulator and on device, but in the browser it would show an error: “cordova is not defined”.
Steps I used:
[download the plugin in the normal ionic way]:
[Then, in relevant component ts file]:
import… [whatever your normal imports]
declare var cordova; … @Component({…
export class [your export class] { … cordova.plugins.notification.local.schedule({ title: ‘Amazing Notification’, text: ‘Hopefully this works!’, trigger: { in: 1, unit: ‘minute’ }, });
I believe the issue is because the ionic-native version of this plugin has not been updated. The ionic docs show “ILocalNotification” params to include stuff like “at”, “every”, and “firstAt”. These params also show up in the plugin as downloaded through ionic-native. But stuff like “at”, “every”, and “firstAt” have been removed from the plugin in the latest version of the plugin itself.
However, building the app with ionic for a device does not recognize these params. So the app is not able to use stuff like “at” (old version) or “trigger” (new version).
Solution would be for the ionic native version to be updated to latest version of the plugin?