Nativescript: Crash on IPv6 network IOS

Created on 10 Jan 2017  路  8Comments  路  Source: NativeScript/NativeScript

Hi guys, when i was testing my app i noticed that it crash when i'm connected to an IPv6 network, in addition for all those who want to publish their app on the app store, i want to remember that apple review team test your app under an IPv6 network.
Basically the problem regards the connectivity module that returns null when you check if the connection is available under IPv6 network.
Here is the solution, you have to change one line in the file:
tns-core-module/connectivity/connectivity.ios.t

function _createReachability(host?: string): any {
    if (host) {
        return SCNetworkReachabilityCreateWithName(null, host);
    }
    else {
        var zeroAddress = new interop.Reference<sockaddr>(sockaddr, {
            sa_len: 16,
            sa_family: 2
        });
        //Use SCNetworkReachabilityCreateWithName instead of SCNetworkReachabilityCreateWithAddress
        return SCNetworkReachabilityCreateWithName(null, zeroAddress);
    }
}

That solution worked for me, i hope that someone from the nativescript team can update the tns-core-modules, thank you.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

feature help wanted ios

All 8 comments

@mounirka I've tried this one, but my app is still crashing. I also got a rejection issue about supporting IPV6 from apple.

@eurica-larazo Can you please provide more details on the errors received upon rejection

This fix worked perfectly fine for us.

Just got rejected. Is this fixed in a newer version or is it still active? I'm using tns-core-modules 3.2.0.

Because this ticket isn't closed i assume that it is still a thing.
Just give it a try ;)

Chiming in here because using Nativescript's connectivity module also caused an app rejection for me. I tried the above solution, but it didn't work for me because the app constantly thought it was in airplane mode. I ended up editing the tns-core-module "Connectivity" to expose two new functions startMonitoringWithHost and getConnectionTypeWithHost. Fortunately, the plugin already has the ability to pass a host in but doesn't expose it. This allowed me to keep my code and still pass IPv6 testing because it never relied on SCNetworkReachabilityCreateWithAddress (https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/connectivity/connectivity.ios.ts#L10). While apple recommends that you don't rely on this approach to test for connectivity, this helped me in a bind. It'd be nice if they'd expose these functions be default. If I've misused the connectivity module or am misunderstanding what happened here, someone let me know.

Hey @jessebacon as NativeScript is open source project you can become a contributor and implement the solution you described above.

Was this page helpful?
0 / 5 - 0 ratings