Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oliexe opened this issue Jul 18, 2020 · 9 comments
Closed

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

oliexe opened this issue Jul 18, 2020 · 9 comments
Assignees
Labels

Comments

@oliexe
Copy link

oliexe commented Jul 18, 2020

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 oliexe added the bug label Jul 18, 2020
@zacbre
Copy link
Contributor

zacbre commented 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

@oliexe
Copy link
Author

oliexe commented 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.

@DavidNorena
Copy link

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

@Elimil
Copy link

Elimil commented Aug 3, 2020

Same problem here, would really require this to work.

@oliexe
Copy link
Author

oliexe commented Aug 4, 2020

Any news on this ?

@GregorBiswanger GregorBiswanger self-assigned this Aug 4, 2020
@Elimil
Copy link

Elimil commented 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.

@rakista112
Copy link

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

@DavidNorena
Copy link

Does it work for windows as well ?

@rakista112
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants