Sometimes you need or want to know if a device is connected to the internet to prevent (or to do) some action. Maybe the device is connected to some Wifi or maybe it’s to mobile data. If you don’t mind what type of connection it has, and you only want to check if it’s connected to any type of internet you can do it easily with this code:
true if the the device is connected to the internet, false if not.