Chrome Packaged App Access Chrome APIs - google-chrome

I'm interested in writing a Packaged App that can access data about chrome, namely the chrome.windows.onCreated and chrome.windows.onRemoved events. If I try to add a listener to either of these, I get an error in the console:
Uncaught TypeError: Cannot read property 'onRemoved' of undefined
Is there any way around this?

The other answers are correct that this isn't directly possible from a packaged app, but there is a solution that meets your needs: You can write an extension as well as a packaged app and have them communicate with chrome.runtime.sendMessage.
The user will have to install both app and extension, but you can make this easy by directing them to the chrome web store from within your application. You can read about this here: Communicating between a Chrome packaged app and a Chrome extension?
Edit: and as pointed out in a comment on that thread, there is a Chrome App Sample that helps demonstrate this in action: https://github.com/GoogleChrome/chrome-app-samples/tree/master/messaging

The chrome.windows API is a Chrome extension API, not a packaged apps API. It is used by extensions to interact with browser windows.
If you can write your application as an extension, it will be able to use that API. Packaged apps, however, don't have the ability to manipulate other windows besides their own.

One simple typo here: It is chrome.windows.onRemoved not chrome.windows.OnRemoved ;)
Note the lowercase o.

Related

chrome.management functionality in apps?

I'm new to making chrome apps and extensions, working on my first app. I need access to alist of the installed apps on chrome with their relevant details and icon, so I used chrome.management. However, when I try to use it in my app, I get the error
'management' is only allowed for extensions and legacy packaged apps,
but this is a packaged app.
Looking at the api page, chrome.management is indeed not listed under the "Apps" tab, but the "Extensions" one.
Is there any other way I can have access to the information in an app? Chrome app launcher did it... not sure if there were any super secret special permissions involved.

Is there a way to launch chrome packaged app from chrome extension

I'm developing a chrome packaged app and chrome extension, both of them communicate with one another, and i want to lunch my packaged app from a chrome extension, is there any way to do it?
Note:
I've tried using the launchApp method of chrome management api, but for some unknown reason the chrome.management is undefined in my chrome extension JS code, although i have specified management permission in my manifest file like so:
"permissions": ["management"]
Does anyone have a idea what is the problem, or there are any other way i can do it ?
Thanks for help:)
There are 2 possible reasons for not being able to use chrome.management.
You have not reloaded your extension properly
You are trying to call this from a content script; you can't do that, since a content script has very restricted access to Chrome API. You need to message a background page to do this for you.
That said, there is a better way to do it if you write both your extension and your app. "management" permission is a big hammer and will generate a warning to the user on installation.
Instead, you can send a cross-extension message to your app. It will wake it up and you can launch your main window from there. See this answer for details.

Citrix Receiver Kiosk App "Unsupported chrome app origin detected"

I searched all over and couldn't find my specific issue here so please excuse me if my search-fu has failed me.
My issue:
I am currently trying to create a kiosk app for my company's chromeboxes. I have the application packaged and published privately on the chrome web store. I get the app to load but once I launch the kiosk app and enter in my company's url I am presented with, "Unsupported Chrome App Origin Detected". The only thing I can find so far about this is to run the flag --disable-web-security. I can only find examples for Windows/Mac/Linux plus that isn't secure. Am I missing something in my Default.cr or manifest.json files? Is this even possible? This is on a vanilla chromebox that isn't part of a Google Apps domain. Do I need to have it added to a Google Apps for Work domain to get this to work? Any help would be appreciated.
Please add your generated chrome extension app id to storefront web.config file. Please have a look at http://docs.citrix.com/en-us/receiver/chrome/1-7/receiver-chrome-deploy.html point 8 at the end on how to do it.
Also please use 1.7 as it supports better Kiosk mode integration.

Can't register Chrome app for GCM

I'm trying to register a chrome app to get a registration id so I test but the chrome javascript console is showing:
Uncaught TypeError: Cannot read property 'register' of undefined
I don't know what's wrong. I got the example from: https://github.com/GoogleChrome/chrome-app-samples#push-messaging
Seems your Chrome APIs are not loaded.
You need to make sure your Chrome APIs are loaded in order to use the push messaging methods.
In order to load the Chrome APIs correctly, follow the step 5 in Chrome developer page to launch your app or extension. For some newer Chrome browser, you can go to Settings -> Extensions -> Load unpacked extension
Had the same problem,
Eventually the problem was that content scripts cannot use a lot of chrome.* APIs.
GCM is one of them.
Source

Can you still create a Chrome packaged app in the browser with manifest 2.0?

All of the examples I've seen show apps launching in their own windows. This may be great an all for chromebook/chrome os, but is there still an option to launch in a browser tab?
No, there is no way to do that. Chrome Packaged Apps are not supposed to run inside a browser. You can, however, open URLs in a browser tab using window.open. But you won't have control of that tab after you issue the command.
If you need some sort of integration/control between your Chrome Packaged App and the browser, you can create an extension and make a communication pipe between the extension and the app - as long as both are running, using the chrome.runtime.sendMessage API.
See this sample for a simple code that does exactly that (two apps and one extension exchanging messages directly, without any server component).
chrome.app.window.create will create a new Window for an App.
If you want window manipulation, you should switch to chrome.tabs API and look for an extension instead of an App.
Reference
chrome.tabs
chrome.app.window