I’m using Local Notifications to send notifications (wow) and when i try to send any on android device i get an error:
06-12 15:48:24.632 14584 14584 E Capacitor/Console: File: http://192.168.1.2:8100/vendor.js - Line 67005 - Msg: ERROR ReferenceError: Notification is not defined
Code
import { Plugins } from '@capacitor/core';
const { LocalNotifications } = Plugins;
[...]
async showInfo(element: Schedule) {
await LocalNotifications.schedule({
notifications: [
{
title: 'Title',
body: 'Body',
id: 1,
schedule: { at: new Date() },
sound: null,
attachments: null,
actionTypeId: '',
extra: null,
},
],
});
}
[...]
Any ideas to fix this?
If you are using Capacitor 3, the import should be the following. All packages got moved out of core.
import { LocalNotifications } from '@capacitor/local-notifications'
I’m using Capacitor 2.4.7, when i try that import i get more errors
06-12 16:29:55.038 19862 19862 E Capacitor/Console: File: http://192.168.1.2:8100/vendor.js - Line 49907 - Msg: node_modules/@capacitor/local-notifications/dist/esm/definitions.d.ts:1:15 - error TS2724: Module '"../../../core/dist/esm"' has no exported member 'PermissionState'. Did you mean 'PermissionType'?
06-12 16:29:55.038 19862 19862 E Capacitor/Console:
06-12 16:29:55.038 19862 19862 E Capacitor/Console: 1 import type { PermissionState, PluginListenerHandle } from '@capacitor/core';
06-12 16:29:55.038 19862 19862 E Capacitor/Console: ~~~~~~~~~~~~~~~
06-12 16:29:55.038 19862 19862 E Capacitor/Console:
06-12 16:29:55.038 19862 19862 E Capacitor/Console: node_modules/@capacitor/core/dist/esm/core-plugin-definitions.d.ts:1243:21
06-12 16:29:55.038 19862 19862 E Capacitor/Console: 1243 export declare enum PermissionType {
06-12 16:29:55.038 19862 19862 E Capacitor/Console: ~~~~~~~~~~~~~~
06-12 16:29:55.038 19862 19862 E Capacitor/Console: 'PermissionType' is declared here.
06-12 16:29:55.038 19862 19862 E Capacitor/Console:
06-12 16:29:55.039 19862 19862 E Capacitor/Console: File: http://192.168.1.2:8100/vendor.js - Line 49907 - Msg: node_modules/@capacitor/local-notifications/dist/esm/definitions.d.ts:2:16 - error TS2665: Invalid module name in augmentation. Module '@capacitor/cli' resolves to an untyped module at '/home/vitor/AndroidApps/StudentPlus/node_modules/@capacitor/cli/dist/index.js', which cannot be augmented.
06-12 16:29:55.039 19862 19862 E Capacitor/Console:
06-12 16:29:55.039 19862 19862 E Capacitor/Console: 2 declare module '@capacitor/cli' {
06-12 16:29:55.039 19862 19862 E Capacitor/Console: ~~~~~~~~~~~~~~~~
06-12 16:29:55.039 19862 19862 E Capacitor/Console:
06-12 16:29:55.039 19862 19862 E Capacitor/Console: File: http://192.168.1.2:8100/vendor.js - Line 49907 - Msg: ./node_modules/@capacitor/local-notifications/dist/esm/index.js 2:27-41
06-12 16:29:55.039 19862 19862 E Capacitor/Console: "export 'registerPlugin' was not found in '@capacitor/core'
I have updated it to 3 and now my problem change

That seems like an unrelated issue with the Network plugin. Did you follow the Capacitor 3 Upgrade Guide?