Reputation: 43
I am using Ionic Capacitor and Framework7 for an application. I want to implement localnotifications using capacitor local notification plugin. However it gives me uncaught referenceError: LocalNotifications is not defined
//Importing plugin
import {Plugins} from '../node_modules/@capacitor/core';
const {LocalNotifications} = Plugins;
//Schedule Local Notifcations
LocalNotifications.schedule({
notifications: [{
title: "Title",
body: "Body",
id: 1,
schedule: {
at: new Date(Date.now() + 1000 * 5)
},
sound: 'res://audio/android/iphone_6.mp3',
attachments: null,
actionTypeId: "",
extra: null
}]
});
uncaught ReferenceError: LocalNotifications is not defined
Upvotes: 2
Views: 1299
Reputation: 11
https://ionicframework.com/docs/native/local-notifications
import { LocalNotifications } from '@capacitor/local-notifications';
const novaNotificacaoId = Math.floor(Math.random() * 10000) + 1;
const dataHoraNotificacao = new Date();
dataHoraNotificacao.setHours(19);
dataHoraNotificacao.setMinutes(0);
LocalNotifications.schedule({
notifications: [{
title: "Notificação",
body: descricaoNotificacao,
id: novaNotificacaoId,
group:'Alerta',
iconColor:'#eb445a',
schedule: {
at: dataHoraNotificacao,
allowWhileIdle: true,
repeats: true,
every: "day",
count: 1
}
}]
}).then(() => {});
Upvotes: -1
Reputation: 1250
Try to import Plugins
like import { Plugins } from '@capacitor/core';
Upvotes: 3