Like me, you never thought about a custom shop with international visibility working from Ho Chi Minh City, commonly known as Saigon in South Vietnam. Qq.
Add to home screen Matteo Spinellis Cubiq. Add To Homescreen ATH is a javascript widget that opens an overlaying message inviting the user to add the web siteapplication to the home screen. This was born mainly to support web app capable applications but extended to a more general purpose use case. Support Development. Add To Homescreen is a free, open source javascript software. It is released under the MIT License which basically grants you complete freedom in usage for open source and commercial applications. That being said the only way for me to subtract hours from my day work and keep implementing this script is through donations. If you find this widget useful and wish to support future development, please consider a donation. Overview. The script opens an always on top message inviting the user to add the application to the home screen. This is currently supported on i. OS and Mobile Chrome. While other devices have the ability to bookmark any website to the home screen, only i. OS and Mobile Chrome have a straightforward way to do it. ATH would technically also work on Windows Phone which has the equivalent Pin to Start option, but Im not currently able to test it on that device. Win. Phone support might be added in a future release if there will be enough interest. ATH by default looks something like this. But appearance is customizable with plain old CSS. The script is compatible with i. OS 6 and Chrome 3. It would be possible to add i. OS5 and older support, but considering the i. OS7 penetration I decided to support the latest two releases only. If theres really interest in older versions I might reintroduce lt i. OS5 support or you could use the previous version of ATH which supports i. OS3 and up. Languages. The message changed in v. If you wish to help please send more translationsBasic Usagev. 3 API changed drastically sorry about that and its not a drop in replacement for v. The good news is that v. ATH versions, so if the users have already seen the message, it wont be displayed again. The easiest way to use ATH is to link the script into your document HEAD and call the add. To. Homescreen function as soon as possible. Eg. lt title Add To Homelt title. To. Homescreen. Thats all you need. ATH automatically hooks to the onload event, checks device compatibility, detects if the app is already in full screen mode and eventually pops up the message. It is not strictly needed to place the script in the document HEAD you can also place it at the end of your BODY, but ATH makes a series of checks that are better done sooner than later. Options. ATH accepts one option parameter to customize the script behavior. To change the start up delay for example you could use the start. Delay option. add. To. Homescreen. Delay 5. This would delay 5 seconds before showing the message. Below the most common options. This is useful mainly for web app capable applications that need full screen viewing to be accessed eg games. First. Visit setting this to true prevents the message to appear the first time the user visits your website. It is highly recommended to enable this option Delay seconds to wait from page load before showing the message. Default 1. lifespan seconds to wait before automatically close the message. Default 1. 5 set to 0 to disable automatic removal. Pace minutes before the message is shown again. By default its set to 1. Display. Count absolute maxium number of times the call out will be shown. Default truemessage you can provide your custom message if you dont like the default. Show custom function executed when the message is shown. Add custom function executed when the application is added to the homescreen. Please note that this is a guesstimate see below. Homescreen ATH tries to detect the homescreen. Supported values are false, true hash, hash, query. String, smart. URL see below. Detect the homescreen. Theres no native event we could hook to to know when a user actually adds the page to the homescreen. Thats also the reason why this script has become so complicated despite the apparent simple task it has to accomplish. ATH development started when Apple introduced the apple mobile web app capable meta tag and stand alone mode with it. When the webapp is in stand alone mode the window. With some caveats of course. Standalone mode is meant for web applications, not standard web sites. The webapp has to be designed with standalone mode in mind, for example links inside your fullscreen app will open in a new browser window hence your app navigation has to be handled with JS. Also, as of this writing Chrome despite support for mobile web app capable doesnt fill the window. So, how can we detect if the app has been actually added to the home screen ATH tries its best to help you in this hard task and the followings are your options. Show the callout only once per user. This is the best, safest and most polite solution of all. Set the max. Display. Count to 1 and the user will be presented with the nasty callout only one time, smartly circumventing the problem. Build a standalone application. When possible try to use apple mobile web app capable. Add a special token in the URL and have the user bookmark the tokenized address. ATH supports hash, query string or smart url tokens. Continue reading for details. I strongly suggest to go with the first option and show the callout only once. Thats the safest solution, but if you want to be more aggressive you can take the token route. First of all you have to choose where to place the token. ATH offers three options hash http www. As soon as the page is loaded ATH adds the token to the page URL no worries, no reload will happen as we use history. State. If the user adds the page to the homescreen the actual URL that will be saved contains the token. If the page already contains the token before ATH could add it, it means that most likely the page has been added to the homescreen. Bear in mind that this is a guesstimate, there are some exceptions but the good news is that it should be pretty rare to have false positive, ie it should never happen to see the popup after the app has been added. Instead it may happen to have ATH think that the app has been added even if it hasnt. Be careful when using the detect. Homescreen option since it may interfere with your application especially if you already use hash or history. State for your navigation. Optimal configuration. Do not annoy your users with frequent callouts the suggested setup is to show the message only once, the second time the user visits your website. To. Homescreen. First. Visit true. Display. Count 1. The above config skips the first time the user comes to your site, so she has time to look around freely. The next time she will be greeted by the cheerful balloon and from that moment on she wont be bothered again. Debug mode. ATH v. By setting debug true some of the preliminary checks are skipped and the message is shown on desktop browsers and unsupported devices as well. You also have the add. To. Homescreen. remove. Session function in your tool belt, which clears the current session. This is very useful when testing various options and the callout seems not to be willing to show up again. This is common because ATH is very conservative, to avoid showing the message by mistake it tries to show it the less as possible. Open the pop up programmatically. Of course you can bypass the automatic triggering and open the call out programmatically. To do so you have to set the autostart false option. To. Homescreen. To. Homescreen its a kind of singleton and returns the instance to the real Add. To. Homescreen class. From there you have access to the show method. Note that no checks are performed to verify if the DOM is ready, if you show the message programmatically thats up to you. If you pass true the callout is shown no matter what overriding most of the preliminary tests. Storage variable name. The user session is stored in a local. Storage variable called org. Storage is domain based, so if you have multiple applications on the same domain ATH cant understand which one you actually added to the homescreen. You can have multiple instances of ATH on the same domain by setting a different app. ID for each installation. Eg. add. To. Homescreen. ID org. cubiq. my. Cool. App. IMPORTANT once set do not change the app. ID If you change the app.