duanli3277 2013-01-25 10:36
浏览 52
已采纳

如何检测用户是在移动设备上并提供应用程序

I've seen on MotoGP.com that when I view the site from a mobile device or tablet I get a message saying 'would you like to see our mobile apps' message and if I choose 'no' that the next time I visit from the same device the message no longer appears. I would really like to introduce such functionality to my site but I'm unsure about a good way to do that, I thought something like this:

  • Using PHP lookup device when user visits site (try to detect OS, iOS or Android for example)
  • Lookup user's MAC address
  • From a table in the DB containing MAC addresses and a boolean flag, check if user has visited before and expressed a preference for not seeing the dialogue box again.
  • If the MAC address is not in the DB show the message
  • If MAC address is in the db with flag set, don't show message.

Any comments on whether this is a good approach or not? It's just what I came up with from scratch and searching seemed to yield nothing.

Thanks for any comments.

David

  • 写回答

3条回答 默认 最新

  • dongyun4010 2013-01-25 10:46
    关注

    The easy way to do this is as follows:

    1. Detect their device via their User Agent. See How do I check if the useragent is an ipad or iphone? on how to do so (Deceptive question name, this method would work for any device/browser). Also available is a convenience class in PHP.

    2. Set a cookie if the user declines, so that you can check in future as to whether you should show your prompt again. See What is the "best" way to get and set a single cookie value using JavaScript on how to do so in Javascript.

    An amalgamation of this and rdurand's idea would create the best solution for you for all mobile devices. Smart Banners are available to devices running iOS6 and above, and provide a neat and tidy way to inform your users that there is a mobile app available for their platform. If the device runs iOS 5 or below, or isn't iOS at all, then the above method I've described should cover their bases too.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度