distriqt / airnativeextensions

DEPRECATED: Original repository of the distriqt native extensions and is no longer maintained. Please see our site for the latest ANEs
https://airnativeextensions.com
2 stars 0 forks source link

iOS 8 - NetworkInfo always return .active = false #270

Closed fdc-dev closed 9 years ago

fdc-dev commented 9 years ago

Hi,

we have a problem to submit our app on Apple AppStore. Your Network info native extension always return false on iOS 8 for wifi and mobile. Can you check our code and give a feedback ? It is working on iOS 7 and Android but not on iOS 8.

try{
    com.distriqt.extension.networkinfo.NetworkInfo.init(DEV_KEY_ANE);
    updateNetwork();

    setInterval( updateNetwork, 5000 );
}catch(ex:Error){
}

protected function updateNetwork():void{
    try{
        var ntf:Vector.<com.distriqt.extension.networkinfo.NetworkInterface> = com.distriqt.extension.networkinfo.NetworkInfo.networkInfo.findInterfaces();

        for each (var interfaceObj:com.distriqt.extension.networkinfo.NetworkInterface in ntf){
            if (interfaceObj.name.toLowerCase() == 'wifi'){
                isWifi = interfaceObj.active;
            }
            if (interfaceObj.name.toLowerCase() == 'mobile'){
                is3G = interfaceObj.active;
            }
        }
    }catch(e:Error){}
}
marchbold commented 9 years ago

Hi, There aren't any interfaces on iOS with the name wifi or mobile so not sure how you intended that code to work? They are generally called something like en0 for the WiFi connection and like pdp_ip0 for the mobile. This may have worked with Android as I believe they are named like that there?

You should be using the isReachable and isWWAN flags to determine your connection type.

if (Network.networkInfo.isReachable)
{
    // Have a network connection
    if (NetworkInfo.networkInfo.isWWAN)
    {
        // Mobile (WWAN) connection
    }
    else
    {
        // WiFi or other connection
    }
}
else
{
    // No network connection
}
fdc-dev commented 9 years ago

Hi,

we trying that code right now and we give you a comeback on that!

Thank you sir!!

From: Michael Sent: Thursday, November 20, 2014 6:24 PM To: distriqt/airnativeextensions Cc: fdc-dev Subject: Re: [airnativeextensions] iOS 8 - NetworkInfo always return .active = false (#270)

Hi, There aren't any interfaces on iOS with the name wifi or mobile so not sure how you intended that code to work? They are generally called something like en0 for the WiFi connection and like pdp_ip0 for the mobile. This may have worked with Android as I believe they are named like that there?

You should be using the isReachable and isWWAN flags to determine your connection type.

if (Network.networkInfo.isReachable) { // Have a network connection if (NetworkInfo.networkInfo.isWWAN) { // Mobile (WWAN) connection } else { // WiFi or other connection } } else { // No network connection } — Reply to this email directly or view it on GitHub.

fdc-dev commented 9 years ago

Its working, Apple have approbe our app, thank you!