0
根據網絡連接我想顯示不同的內容,所以我想確定一個設備是否支持4G或3G連接。我怎樣才能做到這一點?我試圖尋找解決方案,但一直未能找到任何東西。如何確定設備是否支持4G?
根據網絡連接我想顯示不同的內容,所以我想確定一個設備是否支持4G或3G連接。我怎樣才能做到這一點?我試圖尋找解決方案,但一直未能找到任何東西。如何確定設備是否支持4G?
您可以使用cordova-plugin-network-information
插件來檢查用戶的當前的網絡狀態
$ionicPlatform.ready(function() {
var networkState = $cordovaNetwork.getNetwork();
console.log('network state: ',networkState);
if (networkState == Connection.CELL_4G) {
//show the contents to the user while user is in 4g
}else{
//show the contents to the user if not 4g
}
})
網絡狀態的值有