Closed RandomEngy closed 2 years ago
Where you looking to run this in the renderer?
The electron plugins are meant to run in main, as to act as native layer interactions as the official platforms plugins do.
Yeah, I was trying to call it from the renderer process. I was looking for an abstraction model where I could have a platform-agnostic web page that calls into an interface that gives it platform-specific functionality. I was originally trying to use the capacitor electron plugins to do this, but I think this was probably the wrong approach.
My current approach is to set up a "plat" global object that exposes this functionality, set up in preload.ts. I plan to have a different implementation for this object for other platforms.
export interface PlatformApi {
signIn: () => Promise<void>;
getUserInfo: () => Promise<any>;
getIdToken: () => Promise<string>;
getComputerName: () => string;
registerForNotifications: (callback: (notificationData: MutationPushMessage) => void) => void;
getFcmToken: () => Promise<string>;
testAction: () => void;
}
https://capacitor-community.github.io/electron/docs/creatingplugins/
This did not work until I edited
src/index.ts
in the plugin directory. I needed to add:Otherwise it would just run the web implementation of the plugin on Electron.