Handling custom (MyApp://) protocol on MacOS #534

Closed
opened 2026-01-29 16:42:17 +00:00 by claunia · 9 comments
Owner

Originally created by @oliexe on GitHub (Jul 18, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

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.

Originally created by @oliexe on GitHub (Jul 18, 2020). Originally assigned to: @GregorBiswanger on GitHub. **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.
claunia added the bug label 2026-01-29 16:42:17 +00:00
Author
Owner

@zacbre commented on GitHub (Jul 22, 2020):

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 commented on GitHub (Jul 22, 2020): 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
Author
Owner

@oliexe commented on GitHub (Jul 27, 2020):

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 commented on GitHub (Jul 27, 2020): > 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.
Author
Owner

@DavidNorena commented on GitHub (Jul 29, 2020):

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

@DavidNorena commented on GitHub (Jul 29, 2020): Same here, we are dealing with the same issue :(
Author
Owner

@Elimil commented on GitHub (Aug 3, 2020):

Same problem here, would really require this to work.

@Elimil commented on GitHub (Aug 3, 2020): Same problem here, would really require this to work.
Author
Owner

@oliexe commented on GitHub (Aug 4, 2020):

Any news on this ?

@oliexe commented on GitHub (Aug 4, 2020): Any news on this ?
Author
Owner

@Elimil commented on GitHub (Aug 4, 2020):

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 commented on GitHub (Aug 4, 2020): 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.
Author
Owner

@rakista112 commented on GitHub (Oct 6, 2020):

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

@rakista112 commented on GitHub (Oct 6, 2020): They seem to have implemented open-url and open-file recently. #478 @olirehacek @Elimil @DavidNorena
Author
Owner

@DavidNorena commented on GitHub (Oct 6, 2020):

Does it work for windows as well ?

@DavidNorena commented on GitHub (Oct 6, 2020): Does it work for windows as well ?
Author
Owner

@rakista112 commented on GitHub (Oct 6, 2020):

@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 commented on GitHub (Oct 6, 2020): @DavidNorena for Windows you might need to parse process.argv to get the file. Seems like [open-url](https://www.electronjs.org/docs/api/app#event-open-url-macos) and [open-file](https://www.electronjs.org/docs/api/app#event-open-file-macos) only work on macOS.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#534