How to detect desktop browser vs mobile device using wurfl?

こ雲淡風輕ζ 提交于 2019-12-22 18:02:42

问题


I am planning to use Wurfl in a web application in order to distinguish between mobile device and desktop browser. The isMobileBrowser(String userAgent) from net.sourceforge.wurfl.core.utils seems the appropriate function to do that.

Nevertheless looking at the source code of the 1.0.1-rc3 I can see that if the user agent string does not contain the "Tablet" word, it always returns false. I was reading this article http://wurfl.sourceforge.net/newapi/ and I would like to use the fuzzy match that is described there to identify the devices. Could be possible that am I using the wrong function?, if that is the case could you please point me to the right direction?.

Also , do you know where can I find the source code for the 1.0.1-rc4?.


回答1:


You have to use those capabilities:

if(is_wireless_device=false and device_claims_web_support=true) {
the request is from web browser
}

via




回答2:


if($device->getCapability('is_wireless_device') == 'true') { //This is a mobile device } else { // this is for a browser }

This is what I am using to do my mobile device vs browser detection... Works seamlessly at the moment.




回答3:


We tweaked the wurfl.xml file for detecting desktop.

<device id="generic_web_browser" user_agent="DO_NOT_MATCH_GENERIC_WEB_BROWSER" fall_back="generic">
    <group id="product_info">
      <capability name="has_qwerty_keyboard" value="true"/>
      <capability name="pointing_method" value="mouse"/>
       <capability name="device_os" value="**Desktop**"/> <!--Added desktop OS-->
      <capability name="model_name" value=""/>
      <capability name="can_skip_aligned_link_row" value="true"/>
      <capability name="device_claims_web_support" value="true"/>
      <capability name="is_wireless_device" value="false"/>
      <capability name="brand_name" value="generic web browser"/>
      <capability name="can_assign_phone_number" value="false"/>
      <capability name="release_date" value="1994_january"/>
    </group>

We are using WURFL with Liferay plugin and this is working fine for me




回答4:


As of the current Wurfl release there is a "is_tablet" parameter. Wurfl Help Doc



来源:https://stackoverflow.com/questions/2630180/how-to-detect-desktop-browser-vs-mobile-device-using-wurfl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!