简体   繁体   中英

How to open a Chrome Packaged App with a parameter on Windows?

I'm trying to create a file handler on my app, I've not Chrome OS so the only way to try my code is to launch the app from command line with a file in parameter. My question is: how?

I've tried chrome --appid=[TheIdOfMyApp] --[Path of the file to open] but it just opens the app and the entry from my function is the same as when I open Mado with no parameters.

To check if I have an entry I do that :

chrome.app.runtime.onLaunched.addListener(function(items) { 
  console.log(items);
  // The code to open the app's window...
});

It always returns me Object {isKioskSession: false} .

[UPDATE]

My manifest looks like (these are just the file handlers and the permissions parts):

"file_handlers": {
    "text": {
        "types": ["text/md"],
        "title": "MyApp"
    }
},
"permissions": [
    {"fileSystem": ["write", "retainEntries"]},
    {"mediaGalleries": ["read", "allAutoDetected"]},
    "storage",
    "webview"
]

[END OF THE UPDATE]

Does anyone know how to check if an app's file handler is working on Windows? Is my code correct?

Thanks for your help.

Thanks Ben Wells, it's working now. The code (if someone has the same problem one day):

In manifest.json:

"file_handlers": {
    "text": {
        "extensions": [
            "md"
        ],
        "title": "YourApp"
    }
},

And what to do on the command line (remove (x86) if you're on a 32-bit Windows):

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --app-id=YourAppId "C:\Path\To\document.md"

If you want to see if your app has detect a parameter, add the code above (the block who begins with chrome.app.runtime.onLaunched ) to your background javascript.

Command line parameters to packaged apps do not seem to be implemented yet.

The open issue 165573 "Allow launch arguments to be passed to platform apps" states "We need to figure out ... if / how to pass these via the command line".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM