Open albertreed opened 1 year ago
You could try window.CapacitorCustomPlatform?.name === 'electron'
.
Or you could add the following to the preload.ts
file:
import { addPlatform, setPlatform } from "@capacitor/core";
addPlatform('electron', {
name: 'electron',
isNativePlatform: () => true,
getPlatform: () => 'electron',
});
setPlatform('electron');
On the most recent version Capacitor.getPlatform() === 'electron'
should just work, but I have experienced Capacitor being a bit flaky with this.
Apologies if this is in the documentation, I've looked through them and couldn't find the answer. What is the appropriate way of detecting that capacitor is running through electron? The best way I've found is that
Capacitor.getPlatform() !== "web"
ANDDevice.getInfo()
(from the @capacitor/device plugin) returns an object withplatform
set to"web"
which is pretty weird!