I have a PWA where users can redeem stuff. The problem comes when it's PWA on iOS because they don't communicate, so users are able to redeem twice (once in the browser and once on the PWA; if they're sneaky), because PWA doesn't update on what's happening on the browser.
My solution for this would be that every time people are using PWA on iOS and they open the app, it will reload to be updated with the same information the browser one is.
first, I created a function to detect if the user is on iOs and a function detecting if the user is on standalone, to know they're on PWA, so combining these who I created:
if(is_iOS() && isInStandaloneMode()){
window.location.reload(true)
}
But this only created a reload on loop, so I wasn't able to even see the information once.
Is there a way to be able to refresh the page every time the PWA is opened?
Related
This is to do with the way Android handles its activity which is giving me some problems.
Ive developed an app with a webview that loads the facebook page and keeps looking for new notifications.
and any new notification beeps the device.
Im using the JavascriptInterface to check the Facebook DOM for the notification count.
Javascript running with setTimeout.
The only problem is, it all works fine until i have the screen on. If i shut the screen for a few minutes and turn it back on I find that a new notification had already appeared on facebook a while ago but my webview missed it and is reactivated only the moment the screen is back on.
Is there a way to make sure that any data the browser page needs to load must be allowed and always kept active by the WebView ?
In short is it possible to run a sort of internet service like navigate to a page every few minutes and run a script on it regardless of my device state ?
How can you check that a web page is being served under a native app on Windows phone?
You cant use custom user agents, so to date we have done the following...
Check the user agent for Windows Phone, check it for WebBrowser which indicates its served from the WebBrowser windows control, and then try to call a method in our native app to guarantee we are in our app.
However, the latest browser updates to windows have removed WebBrowser from the user agent.
This means there would be delay when viewing the page on Mobile IE, as we would have to try to talk to our native app to see if it's there or not, and wait for a timeout to assume its not there.
So..
1) Is there anyway now to set custom user agents in windows Mobile - everything we have tried to date has failed.
2) Is there another way we can indicate to the page that its running in our app? Inject some JS at the start some how?
3) Any other way to somehow tell the web page what its running in? Cookies, local storage?
We need to know where its running before it has finished loading, so JS scripts can tell where they are running as they load up.
m
I am working on a webapp. I want to count the number of Users that added my webapp to home screen.
suppose my website is.
http://www.example.com
I have added meta tags that allow Mobile users to add it to home screen. I want a count of users that downloaded my webapp. If User has downloaded even if he has not opened that then also I should get notification that User has added it to home screen.
So I need any event that should work when an Webapp is added to home screen.
My webapp is in HTML5
First of all, officially it's not possible, as per the official FAQ:
How can I detect if the app is running as an installed app?
You can’t, directly.
which is again re-iterated
Best practices
Do not prompt the user to add your app to the homescreen. There is no way to detect if the app is running installed or not.
Source: https://developer.chrome.com/multidevice/android/installtohomescreen
You could do some manual checking of the screen sizes though on page load, as chrome can't go fullscreen by hand, but do not rely on this (though for statistical purposes it might be interesting).
Another clarification which might be useful, the application is not downloaded when it's added to the homescreen. All that happens is that a 'link' will be created to chrome with certain parameters. By design little information is disclosed to developers regarding this process to prevent companies from forcing users to 'install' webapps before they would function.
As of 2018, according to https://developers.google.com/web/fundamentals/app-install-banners/:
To determine if the app was successfully added to the user's home screen after they accepted the prompt, you can listen for the appinstalled event.
window.addEventListener('appinstalled', (evt) => {
app.logEvent('a2hs', 'installed');
});
Recent versions of Chrome on Android have added the ability to create full screen Webapps using the 'mobile-web-app-capable' meta tag in much the same way that you can on iOS.
On iOS when you quit a web app and open it again it will always be refreshed; on Chrome it will be up to the operating system resources; and if you re-open the same web app it will often restore the previous app context without reloading the page.
This is causing problems for my Weather Web App as on re-open it often displays old forecast data which can be days out of date.
Is there a way to detect the page re-open so that I can refresh/reload the content?
It seems that the trick is to use timers. Usually, when a webapp is in the background (not a tab background) it's frozen, so it's not executing code. Therefore, if you have a javascript timer that executes every X seconds and on one execution you see that the time passed between executions is far greater then it means that you need to update your data.
I'm developing a web app that shows a counter, and when the counter comes down to 0 I want to notify the user(The counter is on a server, so there won't be a problem with reloading the page).
If the user is on a computer, I'm using a popup for the notification, but if the user is on an Android device, I would like the notification to be shown even if the browser isn't open.(I'm using AngularJS if that would be any help)
Is there a way to do this? I rather not build a special Android app.
Thanks.
//G
I'm afraid no, there is no way to do that. When any android application is not active is... not active, frozen. The browser is not a service, so as far as I know it won't process anything while in background. Even it's possible the OS close the browser if it needs more memory than is available.