Electron.NET icon indicating copy to clipboard operation
Electron.NET copied to clipboard

Handling custom (MyApp://) protocol on MacOS

Open oliexe opened this issue 5 years ago • 9 comments

Electron.NET version: 9.31.2 Target platform: MacOS

I need to handle the login token from the custom protocol (MyApp://) but I am unable to handle the passed arguments to the app. I have successfully registered the application as a protocol hander and it gets launched/opened in the app directly from safari by using : await Electron.App.SetAsDefaultProtocolClientAsync("MyApp"); and setting it in-app plist (As documented).

But I don't know how to handle the passed URL. I can't do that by listening to IRC event (as documented in Electron documentation in handling the custom protocol on MacOS): Electron.IpcMain.On("open-url", Handleprotocol()); The app gets opened/resumed when requested in safari but nothing happens. The IPC message is not published.

Is that a bug or am I doing something wrong ? cant seem to find anything similar in samples or around the net specifically for Electron.NET.

oliexe avatar Jul 18 '20 09:07 oliexe

Hey @olirehacek!

At a quick glance, it doesn't appear that 'open-file' or 'open-url' is implemented in Electron.NET.

https://github.com/ElectronNET/Electron.NET/search?q=open-file&type=Code

zacbre avatar Jul 22 '20 13:07 zacbre

Hey @olirehacek!

At a quick glance, it doesn't appear that 'open-file' or 'open-url' is implemented in Electron.NET.

https://github.com/ElectronNET/Electron.NET/search?q=open-file&type=Code

Thanks @ThrDev , Are you aware of any way/workaround I can handle the custom URL in Electron.NET. We have app that cannot be flipped into production because we can't log in to our service while using the oauth window. It's actually pretty serious.

oliexe avatar Jul 27 '20 07:07 oliexe

Same here, we are dealing with the same issue :(

DavidNorena avatar Jul 29 '20 19:07 DavidNorena

Same problem here, would really require this to work.

Elimil avatar Aug 03 '20 22:08 Elimil

Any news on this ?

oliexe avatar Aug 04 '20 10:08 oliexe

It might be a bit difficult task to implement. Tried to find other solutions for .net core and could not find any. One way would to build an cocoa application wrapper for the protocol handling and make an rest call to electron application. I think that could work and easy to implement.

Elimil avatar Aug 04 '20 13:08 Elimil

They seem to have implemented open-url and open-file recently. #478 @olirehacek @Elimil @DavidNorena

rakista112 avatar Oct 06 '20 03:10 rakista112

Does it work for windows as well ?

DavidNorena avatar Oct 06 '20 03:10 DavidNorena

@DavidNorena for Windows you might need to parse process.argv to get the file. Seems like open-url and open-file only work on macOS.

rakista112 avatar Oct 06 '20 07:10 rakista112