Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Notification must set user model id on win32 #146

Open
txthinking opened this issue Oct 13, 2018 · 7 comments
Open

Notification must set user model id on win32 #146

txthinking opened this issue Oct 13, 2018 · 7 comments
Assignees

Comments

@txthinking
Copy link

I did not find the setappusermodelid api on godoc.

https://electronjs.org/docs/api/app#appsetappusermodelidid-windows

BTW, can we set app id custom like com.mydomain.app

Thanks

@asticode asticode self-assigned this Oct 13, 2018
@asticode
Copy link
Owner

@txthinking ok for app.setAppUserModelId(id).

But regarding your second question, can you point to the Electron corresponding doc?

@txthinking
Copy link
Author

Sorry for the unclear description.
https://www.electron.build/configuration/configuration#configuration

@asticode
Copy link
Owner

thanks!

@CarsonSlovoka
Copy link
Contributor

CarsonSlovoka commented Mar 16, 2022

I spent some time and found the solution and shared it with the people who needed it.


I using the astilectron 0.27| astilectron: 0.51.0 | Electron 11.4.3

I can wait for provision to finish downloading and processing all the related files and then modifying index.js

where "index.js" is located on: https://github.com/asticode/go-astilectron/blob/e7796e5/paths.go#L62

if os:windows default path: %appdata%/[appName]/vendor/astilectron/index.js

// App is ready
function onReady () {
    app.setAppUserModelId("com.mydomain.app");  //  👈  Add this line.  default: electron.app.Electron. 
    // Init
    const screen = electron.screen
    Menu.setApplicationMenu(null)
    ...

But I think this method is still very bad, I hope that the code can be changed directly in the go🤔


see also

@asticode
Copy link
Owner

Yeah, I think that an AppUserModelID should be added in the Options.

I won't have time to work on this anytime soon, but if someone is looking to contribute, feel free to let me know and I'll guide you to make a PR.

@CarsonSlovoka
Copy link
Contributor

I'm trying to use the event to change the ID,

I with it can add on notificationCreate

but it doesn't work. It seems that the event has to be determined after the end of onReady. Even if the hard coding can't change the ID later, for example

    rl.on('line', function(line){
        app.setAppUserModelId("hello world")  // 👈 still not work.
        // Parse the JSON
        let json = JSON.parse(line)

        // Switch on event name
        let window;

I don't know if my inference is wrong or not, but the result of my experiment is indeed like this.


I noticed that atilectron is not a big repository, I want to use embedgo1.16 embed in go-astilectron to embed it directly so that there is no need to maintain two repositories, and even in the js directly using text/template, we can set some initialization place to supply the user to write the code directly into the js, will become very flexible.

Would you accept the pull request like it?

@asticode
Copy link
Owner

  1. Indeed, the best would be to add the AppUserModelID as an attribute to Options so that it gets set right at the start of astilectron

  2. We can't merge go-astilectron and astilectron since some people are using astilectron without go and need this repository to exist independently from go-astilectron

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

No branches or pull requests

3 participants