Chrome app - how to reboot app? - google-chrome

I am creating a Chrome app and I have made a Logout button in the app.
How can I restart/reset the app? (background.js / background page should be restarted)

chrome.runtime API is your friend.
chrome.runtime.reload()
Reloads the app or extension.
Note that this will probably close all windows opened by the app.

Thinking about the user experience I'm not sure if chrome.runtime.reload() is the best what you can do.
It is far much better if you just create a some king of cleanup function which will release unused resources (user's data I mean). The same thing in the app window. If you are using some framework it is probably easy. But in the end reconsider cleaning up instead of rebooting the app.

Related

HTML Service - PWA

Sorry for a noob question - as I've just started with web development half a year ago..
I need your help regarding setting my GAS app into a PWA. Is there such a possibility? I struggle to find any really helpful resources on how to create a service workers and manifest files to work correctly. It'd be extremely helpful for me to get trained on the topic.
Thanks.
Having a valid manifest.json will enable your application to add to home screen of Android, iOS - Safari only, Chrome - All desktop OS.
You can use this link to generate manifest.json for your application and keep in the root of your project and link it using index.html like below,
You can use Workbox to generate service worker for your application.
I don't know what your GAS app is but if it is based on HTML/JS/CSS you can try www.pwabuilder.com for this purpose. It will give you the manifest and the service worker to put in your code.
You can also try the Lighthouse extension in Chrome and activate it when you are on your site. It will tell you if you app is PWA compatible and what needs work.

Can you change a tvOS app built using TVML without submitting an app update to Apple?

When building a tvOS app using TVML, the logic, written in Javascript is downloaded from your server, hosting the files. Does that mean that you could change the Javascript, modifying your app, without having to submit an update to Apple for review?
The tutorial I have been following is
Beginning tvOS Development with TVML Tutorial.
Following the steps in the tutorial, I have successfully started a server locally that is hosting the Javascript files. I can then change part of the Javascript files and then see the change reflected in the app (after I relaunch it). This seems like evidence to me that you could make changes to the app without submitting an update to Apple for review.
Any externally hosted files can be updated. I have personally tested this by adding content and descriptions to my tvml files.
Apple TV will obey any cache headers on the JS script that's served. Additionally, it will only completely reload the app (and the JS with it) if the app has been terminated by TVOS or the user.
Once these criteria are met, it's technically possible to deliver 'OTA' updates to your app without going through App Review again. This is fine with the App Review Guidelines for Apple TV, as long as you're not making 'significant changes' without going through review.

How to allow Chrome Kiosk App configuration access for administrators?

I'm building a Chrome kiosk app that will be in a public space. Users can interact with the app, but there are a variety of settings (server addresses, timeouts, etc.) that need to be set. I'm looking for a strategy on how to allow access to that administration config.
On first run - This is straightforward, but I want administrators to be able to pull it up again.
Detect if the app ran as a kiosk app or manually - This would kind of work, not sure if it's the greatest
Detect some key combination - Ctrl + Alt + Something switches over to the settings page, this feels like people could stumble on it accidentally.
Is there another approach I'm missing?
If your Chrome device(s) is managed you have a further option which is to use the Chrome App Management area within the Google Apps admin interface.
To do this you code your app to use the storage.managed API and this should allow a Configure section for your app within Chrome App Management.
I haven't tried this myself yet but this appears to be the way the Chrome Sign Builder app is configured with its schedule.
Another approach would be to have an administrator login button in a corner of the app. You can set a default password for administrators, which could then be changed in the settings dialog.
You can also think of combining suggestions you have made, first run and then a key combination, and this could bring up a password prompt as also suggested. For an example of this see the Zebradog Kiosk app which is in GitHub so you can see code of how this could be done.
I use ctrl-alt-S at boot. This allows me to login and make changes. I know you have to do a couple of reboots, but it is out of service during admin time anyway.

Activate chrome app from web page?

I am building a packaged chrome app (It is needed as I want to access chrome.socket). I have a website from which I would like to call my app (if installed or ask the user to install it) by clicking a link. Is this possible ? Not able to find any easy way for this workflow.
The url_handlers might be the best way to achieve this.
You can also use the externally_connectable manifest property to declare that your website can connect to your app, then call chrome.runtime.sendMessage or chrome.runtime.connect from your webpage and handle it in an chrome.runtime.onMessage handler in the app.
Which one is better suited depends on your needs. The url_handlers is an easier way, but it will permanently assign the URL on your link to your app, so you won't be able to use it for anything else if the app is installed. The externally_connectable is a harder way, but it enables a much more elaborate bidirectional communication between your website and the app.
You can even use a combination of the two approaches, if you need: launch the app using the url_handlers feature, then establish a communication channel back to the website once the app is up and running.
Apps can now (as of Chrome 31 I believe) register to handle urls by adding url_handlers in their manifest and detecting the url causing the app to launch in the chrome.app.runtime.onLaunched event. If the app doesn't launch, your hosted web site will be loaded an can present an inline installation with chrome.webstore.install.

PhoneGap index page

i know that the index.html page (the PhoneGap startup page) needs to reside on the device. but if we want to create an app who uses third party user authentication before proceeding to core application, so then what we have to do?
Thanks in advance
On android you can change the starting page in the main activity or you can make a redirect in index.html
Well, you don't say if you are platform specific..
And there are lots of third party auth options..
But I can offer two solutions (admittedly my own code etc),
both of them use PhoneGap for Android and PhoneGap Plugins. The key piece of code for me has been the onLocationChange callback feature of the ChildBrowser plugin. Your app can take the user to other sites for auth or whatever, but still get control back.
Tutorial on Using Twitter REST API (OAuth 1, ChildBrowser, jsOAuth plugin)
Free Android App + Source on github : AppLaud App (OpenID, ChildBrowser, custom server)
For authentication, you can have a form in your index.html (maybe under login div) to do a post to an actual webserver.
Then, fetch the data returned from the webserver to let your user access the functionality of your native phonegap application.
You can have the functionality disabled until you receive the successful login from the webserver. If you post via ajax, the webview won't even blink, but you will still get the successful login response from webserver and simply enable functionality on your app after this.
Let me know if this is confusing and I'll try to explain more clearly and
I hope this helps.