We have an angular webapp which should work offline only if used as standalone web app (pwa), but not in the "normal" browser mode. Only very few users need the offline feature, but when angular pwa is enabled, all users will get the "last cached" version of the app and we have to display an alert and reload the page if there are software updates (which happens quite often).
We want the website to ignore all service workers, only when used as installed standalone web app the service workers should drop in.
Is that possible? I could not find any solution so far.
I found a solution myself:
it works, by setting the enabled flag conditionally:
ServiceWorkerModule.register('ngsw-worker.js', {
enabled: environment.production &&
(navigator['standalone'] || window.matchMedia('(display-mode: standalone)').matches),
}),
Related
Can we migrate a PWA to a different domain?
I tried it test wise, simply pointing the domain where the PWA was set up to a different web page.
On the browser, after some refreshing, the new page was loading instead of the PWA. But on the phone where I have the PWA installed, the PWA loads like before.
We would like to avoid that users continue to use the installed PWA, which obviously won't get any updates anymore since its origin changed. It would be ok, to have them install the PWA from its new origin manually if it's not possible to migrate it somehow automatically. But even then, they should be made aware.
Any ideas where to start?
I have a Windows Service written in C# that launches an instance of the Google Chrome browser using PuppeteerSharp. See the launching code below:
string[] chromeArgs = { "--remote-debugging-port=9222" };
Browser browser = await Puppeteer.LaunchAsync(new LaunchOptions()
{
ExecutablePath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
DefaultViewport = null,
Args = chromeArgs,
Headless = false // <-- this is important!
});
Even though I am launching the browser in non-headless mode, I don't see the Chrome browser actually being launched on my machine. I have confirmation that the browser does actually get launched because I see it show up in Task Manager.
I suspect that the Chrome browser is not visible because it is being launched from a Windows service which is a background process, so Chrome is automatically being launched as a background process. Is it possible to launch Chrome as a non-background process so I can see it? And if so, how?
I suspect that the Chrome browser is not visible because it is being launched from a Windows service which is a background process, so Chrome is automatically being launched as a background process. Is it possible to launch Chrome as a non-background process so I can see it? And if so, how?
Win32 services run in a separate session from user-visible applications. Among other reasons, this prevents a security vulnerability known as a shatter attack. So it's not just on a different desktop; it's in a different desktop, which is in a different Windows station, which is in a different user session.
While there is a hack you can put in that allows displaying a UI from a Win32 service, that hack should not be used. It requires lowering the security of the entire system, additionally lowering the security of that service in particular, and may stop working with any future Windows Update.
The proper response to "how do I show a UI from a Win32 service" is "you don't". There are a couple of alternatives:
Do you really need a Win32 service? Perhaps it should just be a regular app that is auto-run on login? Usually, Win32 services are used because they can run without a login, but in that case, I'd have to ask where exactly would you show the UI if there's no user logged in? So first, consider whether your application should really be a Win32 service or not.
If you do really need a Win32 service, and you need to show a UI, then the proper architecture is to split the existing app into a Win32 service and a separate executable that runs on login. When the Win32 service wants to display a UI, it uses some form of inter-process communication to tell the autorun application to display the actual UI.
Note that with option (2), you'd also need to decide how to handle the situation where there are multiple logged-in users (e.g., Remote Desktop sessions), and determine which session you want to display the UI on.
I am trying to build an offline-data persistent web application with Service Workers. I managed to have it working on my laptop Chrome (51) and it loads the cached files and displays an offline message when I simulate being offline via the Chrome DevTools - Network tab.
I uploaded the application to github to make sure it is available with https (https://mguardos.github.io/index.html)
However, when I try to test it with my Android Chrome (Nexus 5 - Android 6.0.1 - Chrome 51), the application loads fine when online, but if I set the plane mode on and reload the page, the browsers is not checking the service worker but displaying the offline message directly
"You are offline.
Your devide is offline.
Try: ...
ERR_INTERNET_DISCONNECTED"
Is there any option that I have to enabled in my Android Chrome for Service workers to work?
Thanks for any tip
PS (edited): Same issue occurs with Opera 37 on Android 6.0.1. However, the Registration service happens properly for both Chrome and Opera in the background (validated via an alert upon the registration method is successfully completed)
PSS: The link above tries to be a very basic example of combining service workers with AppCache, to retrieve localStorage and IndexedDB data so any constructive critic would be very much appreciated on top of the original question
The problem in Chrome seems to be that it requires the entry '/' to be added to the files to be cached for the Service Worker. I added that entry and I could see the application working fine while offline with my Android
However, the problem with Opera remains the same, I can even replicate it with the https://airhorner.com app
Just Open Opera (make sure you clean the cache before)
go to https://airhorner.com (the application loads fine - although it does not sound)
Activate airplane mode
Reload the page (the application still loads because it is reading from local cache)
Close the browser or simply go to a different address
Then go back to https://airhorner.com (The Offline message I added to the original question appears)
I will continue my investigation and will potential create a new question just for the Opera browser, as this question has been answered for Chrome
I have a simple web app that I want to use locally (i.e. I don't want it to ever access the network). All the code is packaged according to the Safari Web Content Guide. I was successful in downloading my web app to my iPhone. I noticed, though, that even though my web app doesn't connect to anything remotely, there will be a network access (the network access indicator fires).
I suspect that iOS is checking to see if the web app is fresh (i.e. checking the cache manifest to see if it needs to update any files). Is there a way to prevent this? It really screws up the user experience.
The never-ending network spinner is a bug in iOS; you won't be able to get around it with a web app:
http://www.devthought.com/2012/09/22/understanding-the-ios6-ajax-bugs/
I need to create a web app for a client, and one of the requirements is whenever an event is triggered there should be some desktop notification in Windows XP/7 that tells them of the event. Similar to the balloon that pops-up when a new file is added to a folder in Dropbox.
I am using Rails for the web app, but have never done any desktop development. What should I be looking at?
Would this: Growl Notifications from a Web Server
plus Growl for windows meet your needs? http://www.growlforwindows.com/gfw/developers.aspx
It may be worth looking at Noti.
This tool allows web apps to push notifications to a small app running on OS X, Windows and Linux.
Would RSS-enabling the application, coupled with a RSS widget on the desktop, suffice? This has a few drawbacks - for example, it requires setup on the workstations and is not immediate. But it is non-proprietary.
If this is a Windows environment, perhaps the application could use the Windows command msg.exe to pop up an alert box (assuming Windows messenger service is enabled on the workstations).
You can use Telegram (desktop portable version included) with TeleNotify gem. Downside is, your app must have HTTPS. But with CloudFlare you can get your app working with SSL for free, even without changing your source code.