Skip to main content

connectToNetwork

Connect to a network with internet connectivity and return a promise of success otherwise TetheringError will be thrown with the error details.

info

Due to the limitation of newly Android versions please read Selection Criteria and Network Suggestions although the system only decides which network to connect to we use a workaround to force it to connect but we cannot guarantee that would work always so in case of failure you should use saveNetworkInDevice or openWifiSettings as fallbacks.

caution

You must have

  • CHANGE_NETWORK_STATE
  • CHANGE_WIFI_STATE
  • ACCESS_COARSE_LOCATION
  • ACCESS_FINE_LOCATION

permissions granted to your App

Returns: Promise

ParamsTypeDescriptionDefault
ssidStringnetwork namerequired
passwordStringnetwork passwordnone
isHiddenBooleanwhether a network is hidden or notfalse
timeoutnumberin case the connection failed within that time you will get a timeout error which you can use for fallbacks6 sec