สำนักวิทยบริการและเทคโนโลยีสารสนเทศ (สวส.)

Office of Academic Resources and Information Technology

​ionic framework check internet connection


1.ติดตั้ง plugin โดยใช้คำสั่งดังนี้
cordova plugin add org.apache.cordova.network-information
2.เขียนสคริปท์ในไฟล์ app.js เพิ่ม

if (window.Connection){
       if(navigator.connection.type == Connection.NONE) {
        alert("Internet Disconnected on your device"); 
       }
    }
3.จะได้ผลลัพธ์ดังนี้