Cordova local notification plugin via react

I’m new to Cordova and mobile development in general. I’m using VoltBuilder to build my React app into a mobile app — I build React, zip it, and upload. I purchased the paid version in order to be able to schedule local notifications in the app.

In my config.xml, I have:

<plugin name="cordova-plugin-local-notification" source="npm" />

In my React app, inside the deviceready event, I try to print:

cordova.plugins.notification.local.getDefaults();

However, the getDefaults function does not exist on the local object. The local object contains properties like:

  • _commonOptions
  • _androidAlarmTypes
  • _defaults
  • _androidSpecificOptions

…but it does not include getDefaults or schedule functions.

I also tried looking for these functions under the navigator object, but didn’t find them there either.

I’ve checked the app permissions — the app is allowed to send notifications and there are no restrictions.

How can I implement local notifications in my React app using this plugin? I would really appreciate detailed instructions.

Can you share your project (or even better, a minimal project just showing the problem)? If the code is proprietary you can share it directly with support@volt.build.

Not sure if this will help, but I’ve put together a minimal setup — two projects.

  1. The React app itself, where the main file simply saves the cordova.plugins.notification.local object to state. When I try to call the getDefaults() or schedule() functions, an error appears.
  2. A build project for VoltBuilder. It’s mostly copied from the example in the documentation with almost no changes, except I added:
<plugin name="cordova-plugin-local-notification" source="npm" />

I’m not sure if I’m using the plugin correctly, although all the other plugins, like dialogs, work without issues.

https://github.com/Natalia280899/react-app-volt-build/blob/main/src/App.tsx

https://github.com/Natalia280899/volt-build/blob/main/config.xml

I notice in your build project, you are missing this line in your index.html:

 <script src="cordova.js"></script>

Can you try adding that and see if it helps?

Yeah, I tried. Just forgot to push it. I tried adding it to the head tag, but it doesn’t seem to have any effect at all

gosh, shedule() function finally worked. Thank you very much for help!

How did you solve the issue?