WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!
Provide a general summary of the issue.
Initializing an array called notification with parameter below:
let hr = 10;
let mn = 30;
let notification = {
id: alarmId,
title: AlarmTitle,
text: AlarmText,
trigger: { every: { hour: hr, minute: mn} }
};
this.localNotifications.schedule(notification);
Error is coming :
[ts]
Argument of type '{ id: any; title: any; text: any; trigger: { every: { hour: string; minute: any; }; }; }' is not assignable to parameter of type 'ILocalNotification | ILocalNotification[]'.
Type '{ id: any; title: any; text: any; trigger: { every: { hour: string; minute: any; }; }; }' is not assignable to type 'ILocalNotification[]'.
Property 'length' is missing in type '{ id: any; title: any; text: any; trigger: { every: { hour: string; minute: any; }; }; }'.
cordova -v): 7.1.0cordova platform ls):Ionic Version (if using Ionic)
-> @ionic/cli-utils : 1.19.0
-> ionic (Ionic CLI) : 3.19.0
trigger parameter for scheduling notification is not working at all.
_Tell us what should happen_
_What were you trying to do?_
I wanted to set the notification at specific time but after setting up time from time picker , notification comes instantly when i use action parameter but for trigger i am getting error
Any joy?
@markterrill - any solution for this error?
The plugin version you are using is not compatible yet with Ionic Native (see Readme file). The ionic wrapper is not part of this plugin. So you should schedule your notification the way it is indicated in the readme file.
Instead of using : this.localnotifications.schedule({..})
try :
cordova.plugins.notification.local.schedule({
...
});
@bilelmoulahi - Thanks you , it's working now :-)
@bilelmoulahi 's answer got me to get the code working again. However, I had to slightly change the code due to typescript errors. So, my working version looks like
cordova.plugins['notification'].local.schedule({
text: 'Test notifucation',
trigger: {in: 2, unit: 'hour'},
});
NOTE: cordova.plugins.notification had to changed to cordova.plugins['notification']
Ionic:
ionic (Ionic CLI) : 4.10.2 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.1
@angular-devkit/build-angular : 0.12.4
@angular-devkit/schematics : 7.2.4
@angular/cli : 7.2.4
@ionic/angular-toolkit : 1.3.0
Cordova:
cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 6 other plugins)
System:
ios-deploy : 1.9.4
ios-sim : 7.0.0
NodeJS : v8.10.0 (/usr/local/bin/node)
npm : 6.5.0
OS : macOS Mojave
Xcode : Xcode 10.1 Build version 10B61
@sameera207 thank you for your solution. this works for me.
Most helpful comment
@bilelmoulahi 's answer got me to get the code working again. However, I had to slightly change the code due to typescript errors. So, my working version looks like
NOTE:
cordova.plugins.notificationhad to changed tocordova.plugins['notification']