Open RandomEngy opened 2 years ago
Can confirm. I noticed the same issue.
@RandomEngy I just want to say... Thank you for sharing your workaround. You probably saved me hours/days of going in circles trying to find a solution. It would have taken me entirely too long to determine that importing the constants from electron-push-receiver
was the reason for my preload script failing to load, based on the console's error messages. Seriously, thank you.
@vialoh Hi, can you please share your snippet of how you initialize the reciever? I tried using strings instead of imported event names but I still get the same error
@weeks6 Sure! I'm using @capacitor-community/electron, and you can see how I've integrated electron-push-receiver
here in this commit: https://github.com/molecule-dev/molecule-app/commit/762188931c98f2835718e147abd4a5c934af555c
And if you're curious as to how it's integrated into a React app: https://github.com/molecule-dev/molecule-app/commit/b4b94cd9c31e559dc250835dfb099b1ac008b59e
Plus some instructions for configuring the GOOGLE_CLOUD_MESSAGING_SENDER_ID
: https://github.com/molecule-dev/molecule-app/commit/dd767c87625448c0ca5e19378b202379c429453a
The molecule-dev/molecule-app
is a work in progress which often has its git history overwritten (for good reason if you take a look at what it's for), so if these links to the commits above ever break, ping me here and I'll update this comment.
@vialoh Thanks! That helped me a great deal!
I'm using Electron 16.0.4 and am initializing the electron-push-receiver from the isolated context preload script in the renderer process. I'm getting this error on importing the module:
It appears that v1.0 of
electron-config
is making a check:electron.app || electron.remote.app
. This throws since both are null in newer versions of Electron. It appears the new package for storing data iselectron-store
. I think it might be fixed just by updating to use that instead.I was able to work around this by using the literal strings when listening for the push events rather than trying to import the values in the preload script.