Search code examples
ibm-mobilefirst

MobileFirst 7.0 network checking always fetched with "WIFI"


I'm following the javasript client side API to do a detection of end-user network. The following code always seems to be fetched with a return value of "WIFI";

var netWorkType = "";
var isNWConnected = false;
WL.Device.getNetworkInfo(function (networkInfo) {
    isNWConnected = networkInfo.isNetworkConnected; //here, API seems to return a String value of "true" or "false" not boolean type
    netWorkType = networkInfo.networkConnectionType;
    if(isNWConnected == "true"){
        var str = "you are connecting with a " + netWorkType + " network";
        alert(str);
    } else {
        alert("NONE, checking your cellphone networking setting");
    }
});

On my iPhone 5s with iOS 8.4, 2G/3G or 4G carrier network return with "WIFI".

I don't know whether it's a bug of WL or maybe I'm doing somethin' wrong...

btw: MobileFirst 7.0 Server version: 7.0.0.00.20150312


Solution

  • Looks like it indeed always returns wifi. This is a bug.

    You'll need to open a PMR (support ticket) to have the development team investigate and provide a fix.

    As a workaround you can use the Connection API provided by Cordova. I tested it and it returns the expected result: http://docs.phonegap.com/en/edge/cordova_connection_connection.md.html