如何判断android用户是否来自主屏幕应用程序 [英] how to tell if android user came from home screen app

查看:104
本文介绍了如何判断android用户是否来自主屏幕应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法判断用户是否通过主屏幕切换来到您的网站?使用iOS,我可以使用以下javascript代码来检测用户是否通过主屏幕快捷方式打开页面:

  if((导航器中的'standalone'&&!navigator.standalone&&(/iphone|ipod|ipad/gi).test(navigator.platform)&&(/ Safari / i).test( navigator.appVersion)){
window.location ='index2.html';
}

我发现你可以用android做任何类似的事情。任何帮助都会非常感激:)

解决方案

简短的回答是不。



从Android主屏幕启动的网站书签小部件不包括引用者(我只是这样做(除非是天气,时钟或音乐,显然是人们做的在他们第一次设置手机时使用!?)。



即使对我来说,喜欢Android小部件的人(特别是在我的Android平板电脑上),更大的书签管理器小部件让我控制得太少,无法吸引我,单个网站书签小部件,它提供了不错的控制,对我来说看起来不是很好,我从不使用它,因为它只是一个红色书签,中间嵌入了一个小小的图标。



无论如何,回到原来的问题。



没有写一个小工具,你的网站的每个Android用户都愿意在他/她的设备上安装。您唯一的选择是尝试在用户尝试为您的网站添加书签时进行干预。干预只会在用户不设置清除任何附加到其上的url参数的书签时才会起作用。例如,您可以将用户当前浏览您网站的日期附加到网址,如果用户为该网址添加了书签,那么相同的网址可能会在更晚的日期出现。这将是尝试查看用户是否来自书签(或某个地方保存的链接)的一种方式。



但即使您可以这样做,也只会告诉您用户是通过历史记录栏自动完成,还是通过主屏幕启动的书签来到您的网站,或者只是通过普通的Chrome启动的书签,而不是直接输入地址(我没有提到谷歌搜索,因为用户使用谷歌搜索,谷歌至少会给你的参考者)。


Is there a way to tell if a user came to your website via a home screen shorcut? With iOS I'm able to use the following javascript code to detect if the user opened the page via the home screen shortcut:

if (('standalone' in navigator && !navigator.standalone && (/iphone|ipod|ipad/gi).test(navigator.platform) && (/Safari/i).test(navigator.appVersion)) {
            window.location = 'index2.html';
        }

i can't find that there is anything similar that you can do with android though. any help would be greatly appreciated :)

解决方案

The short answer is "No."

A web site bookmark widget launched from the Android homescreen does not include a referer (I just checked).

Furthermore, the mechanism for installing/bookmarking a web app locally on Android is completely different than on the iPhone, and definitely not as full featured (as reported on the issue tracker).

[...]

I expressly endorse this request, as it is not possible to offer a native-looking WebApp in Android at the time without implementing a shallow hull of an App, containing just a WebView (or implementing one of the popular Frameworks like PhoneGap or apparat.io).

This leads to the point where you have to pay 25 USD for offering a native-looking WebApp on Android. The same thing is free on iOS devices - and more elegant

By the way, the web site owner above is slightly wrong. In android, he could just offer the app from his web site without paying the $25 to go through the Market/Google Play since Android uses free self-signing certificates. Thought, his main point remains. That is not an easy thing to do and the end result may not be very usable unless he puts a lot of work into it.

And comparatively speaking, I'd say that on Android, its stripped-down bookmark widget homescreen functionality, compared to iOS, is almost never used.

For instance, I personally use the main chrome browser, or google search, or an existing app, as my main entry points into any of the web sites I visit.

In the screenshot above, the three red bookmarks on the left are actually web bookmarks. And just to contrast them with non-web bookmark widgets that I actually like, I've also placed two ebook widgets on the right.

Also, I consider myself a power user and an avid early adopter of many features, and I do use some of the less used Android widgets, but according to HTC, I'm only part of 10% of people who do so (unless it's for weather, clock(s), or music, which apparently people do use when they first set up their phone!?).

And even for me, someone who loves Android widgets (especially on my Android tablet), the larger bookmarks manager widget gives me too little control to be attractive to me, and the single web site bookmark widget, which gives decent control, doesn't look very good to me and I never use it since it's just a red bookmark with a tiny favicon embedded in the middle of it.

In any case, coming back to your original question.

Short of writing a small utility that each Android user of your site would willingly install on his/her device. Your only alternative would be to try to intervene when the user tries to bookmark your site. And intervening would work only as in so far as the user doesn't try to clean the bookmark of any of the url arguments appended to it when he sets it. For instance, you could append the date the user is currently browsing your site to a url, and if the user bookmarked that url, that same url might appear at a much later date. That would be one way of trying to see if the user came from a bookmark (or a saved link some place).

But even if you could do that, that would only tell you if the user came to your site via a history bar autocomplete, or via a homescreen initiated bookmark, or just via a normal Chrome initiated bookmark, instead of just typing the address straight in (I'm not mentioning google search, because with the user using google search, google would give you the referer at least).

这篇关于如何判断android用户是否来自主屏幕应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆