Open cohenstyle opened 1 year ago
@cohenstyle Thank you for posting this issue. I'm facing the same problem as well. From what I understand, the loadPluginImplementation() method of '@capacitor/core' (https://github.com/ionic-team/capacitor/blob/d0ab34fb04d63d6feba496a7c2bd802b455861d6/core/src/runtime.ts#L100) returns undefined instead of returning the plugin code for the platform.
@cohenstyle Have you found a solution or workaround for this issue?
Hi @cohenstyle,
After investigating further in my index.ts
file, where I reference the code for Electron, I realized that I had pointed to a different reference than the one loaded by Electron when capacitor-electron loads the plugins. In fact, it takes the class name and not the object name that we want to call with the plugin.
import { registerPlugin } from '@capacitor/core';
import type { SerialPortPlugin } from './definitions';
const SerialPort = registerPlugin<SerialPortPlugin>('SerialPort', {
web: () => import('./web').then(m => new m.SerialPortWeb()),
// electron: () => (window as any).CapacitorCustomPlatform.plugins.SerialPort, => my error SerialPort instead of SerialPortElectron
electron: () => (window as any).CapacitorCustomPlatform.plugins.SerialPortElectron,
});
export * from './definitions';
export { SerialPort };
We may not have the same issue, but sometimes, it's these small details that cause our problems. Perhaps you are facing the same issue, and if so, I hope I could help you.
Best regards.
Thanks @dimer47. I've been focused on Android lately and am having trouble getting electron running in my project altogether at the moment. I'll likely give this a shot when I get it running.
Describe the bug I'm developing a plugin in the same package as my app to make it easy to iterate. I'm able to get it into the window by adding it in electron-plugins.js But even though I've added an electron platform to the registerPlugin call, whenever I try to use it I get a not implemented error. I may be missing another place I have to hook it up? When I call the echo function (only implemented function) on the CapacitorCustomPlugin.plugins.name object it seems to work.
To Reproduce Steps to reproduce the behavior:
Create a plugin in a project and manually add it in electron-plugins.js
Expected behavior Be able to use it.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):