목차

Connection

설명

제약사항

Android

N/A

iOS

Cellular Network

환경 설정

Android

<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

iOS

    <feature name="NetworkStatus">
        <param name="ios-package" value="CDVConnection"/>
    </feature>

속성

connection.type

function checkConnection() {
    var networkState = navigator.connection.type;

    var states = {};
    states[Connection.UNKNOWN]  = 'Unknown connection';
    states[Connection.ETHERNET] = 'Ethernet connection';
    states[Connection.WIFI]     = 'WiFi connection';
    states[Connection.CELL_2G]  = 'Cell 2G connection';
    states[Connection.CELL_3G]  = 'Cell 3G connection';
    states[Connection.CELL_4G]  = 'Cell 4G connection';
    states[Connection.NONE]     = 'No network connection';

    alert('Connection type: ' + states[networkState]);
}

checkConnection();
유형네트워크 상태
Connection.UNKNOWN알 수 없는 네트워크 상태.
Connection.ETHERNET이더넷
Connection.WIFIWi-Fi
Connection.CELL_2G2G
Connection.CELL_3G3G
Connection.CELL_4G4G
Connection.NONE네트워크를 지원하지 않음.

참고 자료