Search code examples
androidioswebwificellular-network

Website detects if a phone is using Wi-Fi or Cell service


I have some videos on our page, and am curious if there is anyway for the website, or something on the back-end to detect if the user is connected to the site either through Wi-Fi, or through their cellular network? I know Google Play can detect it, because I've seen it pop up messages saying the update I'm about to download is considered "large" and I should connect to Wi-Fi before I try to download it. This warning pops up only when I have Wi-Fi turned off.

Is there a way to have the website be able to detect how the user is connected (Wi-Fi or cell network), and pop up a warning to the user when they try to play a video if they are on a cell connection?


Solution

  • There is no easy way to do this, however you could use the clients IP address and an IP address lookup service to determine if it is on a carrier's network or not.

    You might also look into: http://php.net/manual/en/function.geoip-isp-by-name.php

    Google Play is a different case because it is an app not a website and can interface with the phone's OS.