electron-userland / electron-windows-store

:package: Turn Electron Apps into Windows AppX Packages
MIT License
678 stars 86 forks source link

setAsDefaultProtocolClient not working in appx #83

Closed dpalou closed 7 years ago

dpalou commented 7 years ago

Hello,

as the title says, setAsDefaultProtocolClient isn't working when creating an appx file, but it does in my .exe file.

In my Electron main file I have the following line:

app.setAsDefaultProtocolClient('moodlemobile');

I'm using electron-builder to package the app. I added a "protocols" attribute in my package.json and I included the moodlemobile protocol in there too. To package the app, I run:

build --dir

This creates a .exe file. If I run this .exe file, my app starts and it's able to capture links with moodlemobile:// protocol just fine. Everything works perfect.

After that, I run electron-windows-store to create an appx file. If I install this appx file and run the app, it does NOT capture the moodlemobile:// links, it's as if I didn't have the app installed. This is the command I'm using to create the appx:

electron-windows-store --input-directory .\dist\win-unpacked --output-directory .\build --flatten true -a .\resources\desktop -m .\AppXManifest.xml --package-name MoodleDesktop

I tried using the default manifest and it doesn't work either. Any ideas?

dpalou commented 7 years ago

I was able to make it work by adding these lines in my manifest and overriding the default manifest created by electron-windows-store:

<Extensions>
    <uap:Extension Category="windows.protocol">
        <uap:Protocol Name="moodlemobile">
            <uap:DisplayName>Moodle Mobile URI Scheme</uap:DisplayName>
        </uap:Protocol>
    </uap:Extension>
</Extensions>

It could be interesting to support this using the command so people doesn't need to create their own manifest.

Anyway, I'm closing the issue :)

abardik commented 7 years ago

Hi @dpalou,

Is it possible to use your manifest extension with electron-builder?

Thank you.

abardik commented 7 years ago

If you have installed electron-builder locally for a particular project, the quickest but not elegant way is to add Extensions section provided above to node_modules/electron-builder/templates/appx/appxmanifest.xml (it should be inserted inside Application section).

setAsDefaultProtocolClient call and an appropriate code to process the args are the same.

dpalou commented 7 years ago

Hi @abardik,

I don't know if it's possible. We have our own manifest and we override the default one when we package the appx using electron-windows-store.