How does iOS Safari determine when to show the location services dialog? - javascript

How does iOS Safari determine when to show the location services dialog? It seems if the user grants permission twice for a given domain, the choice is cached (just on that device). For how long? Are two denials also cached?
Has the algorithm changed between versions of iOS? (On a version of iOS before 10.1.1, I always gave google.com permission, but I kept getting prompted every time I visited.)
Is the algorithm different when the mobile app supports "save to home screen?" (And is started from the home screen)
Background info:
When a web app requests the user's location, iOS first prompts the user for permission. An example of this is on google.com when "Use precise location" at the bottom is tapped.
This question is similar, but there are no answers, yet: How does mobile safari determine when to prompt user to share location?

Related

Remove Mobile Safari Mobile Version Notification Aframe

I need to remove the notification you receive in mobile Safari in Aframe that you receive when you first open the site, the one that says "Setyour browser to request the mobile version of this site and reload to enjoy immersive mode."
The reason is that the project will be deployed on company issued devices where settings are managed by IT or the users may be too confused to go through the experience.
You can disable via the device-permission-ui component. Notice that magic window and vr mode won’t be available if the site is requested using desktop mode.

How do I detect the difference between Safari in Gmail Webview and Safari launched from Home Screen on iOS 11 when the User-Agent does not change?

I maintain an app that sends notifications to users containing links to forms. Those forms have image-capturing controls. These controls break in Safari when the app is opened in Safari through another app in a webview.
Okay, so I look at having Javascript detect if it is in a webview and try to direct the user to open their browser directly. Except, well, the user agent strings for Safari when opened via Gmail and Safari when opened directly from the Home screen on iOS 11 are identical.
So, all approaches for detecting webviews I currently see on Google like NPM's is-webview and User-Agent/regex predicates do not work. The only meaningful difference I can see is that navigator.mediaDevices.getUserMedia is undefined in the webview.
But knowing getUserMedia is undefined does not tell me if the user simply CANNOT use the controls, or if the user just needs to get directed to their default browser outside the scope of the app they used to access a notification.
Before we go through the trouble of decorating my links with additional data to track where users are coming from, is there a way to detect if Safari is opened via another app on iOS 11 if the user agent string does not change?

Facebook in-app browser not sharing location

i have a mobile friendly website which makes use of browser location to give nearby places of interest. Its working fine in all browser but when i try to load it from facebook app (Facebook app makes use of its own in app browser to open links ) it waits infinitely to take locations even though my phone's location in shared.
Can any one help in
How to get location from facebook in app browser.
or
How to by pass fb in app browser to open my link in a browser.
Thanks

How to detect that User has added webapp to the homescreen on mobile device?

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');
});

Can I Create Chrome Application Shortcuts Programmatically from a Web Page?

I've thought about using Chrome and HTML5 local storage to create a useful app and sell it. The problem I think I would have, however, is the delivery mechanism to get this installed on one's computer. Let's say the app was wikipedia.com (although it isn't). Manually one can go there with Chrome, then choose the wrench icon, Tools, Create Application Shortcuts, and make a desktop and application menu icon for the app.
Okay, fine, but is there a way I can compose a web page link or form button such that it does this for me? In other words, one clicks a button or link and it shows the Create Application Shortcuts form. I am hoping that there's this little-known way on Google Chrome to use either HTML or Javascript to trigger showing that form.
As for those who don't have Chrome, I can detect that and give them a button they click that emails them. In the email, it will give them instructions for installing Chrome and then another link so that they can visit this page in Chrome in order to get the button that shows the Create Application Shortcuts form.
For now, until a better answer can be provided, this is sort of the technique for deploying a desktop app with Chrome, the manual way, and without having to register in the Chrome Store:
After the user purchases a product, email them the serial number for registering their product and a web URL to install this new product.
The web URL is the actual URL of the web app. However, it doesn't display its normal content by default. Instead, the web app is in "installer mode". It does this by looking at a 200 year persistent, encrypted, registration cookie that may not already be installed. (Note if they delete cookies, there's no harm done -- it just asks them to re-register again.)
The first thing the web app does in Installer Mode is detect user agent. If it finds this is not Chrome, it gives them a link to install Chrome and tells them to follow the instruction email again that they have already been sent, but using Chrome to do this. (You might also want to provide a form to resend them the instructions and serial number again.)
The user either installs Chrome and returns back to this page again, or is already a Chrome user. The Installer Mode then shows a message that reads, please press the ALT-F key in Chrome, or press the Wrench icon in your toolbar, and choose Tools > Create Application Shortcuts, check the two checkboxes, click OK, and then click the "Task Performed" button below.
The user follows the instructions and creates their desktop/application shortcut and then clicks "Task Performed".
The user then sees a registration form where they are to type in their serial number they were emailed. The user enters this in and clicks the Register button.
The server validates the registration and then stores a persistent, 200 year encrypted cookie that basically says, "This guy is registered." This keeps the web app from running in Installer Mode.
The Installer Mode is still active, however, and shows them the final prompt: "You may close your browser and run the icon for the new app from your desktop or application shortcut that you created. The icon is named '{insert name here}'."
They close their browser and doubleclick the icon. The application loads, the registration cookie is read, and the web app no longer runs in Installer Mode -- it shows the application content like it normally would. Besides the fact that this is not a 100% truly automated install, the only drawback is that, since the main page is not a local file (cached), the web app can't really work offline completely. Sure, it can use HTML5 offline storage, but doubleclicking the desktop shortcut will always connect to your web app site.

Categories

Resources