Xamarin iOS IPv6 App Store Rejection

后端 未结 3 621
难免孤独
难免孤独 2021-01-21 23:18

We have been building a iOS app that is about Client - Server App. We are using an SQL connection and WCF web services in the iOS app with Xamarin.

SQL Connection Code :

3条回答
  •  花落未央
    2021-01-21 23:43

    There's already some helpful stuff in the comments, but I think that your main problem is that you had the IPv4 to IPv6 mapping the other way around. You were leaving the IPv4 address as it was and mapping the IPv6 address to IPv6 which it already was.

    Take a look at the fixed version:

    string input = "10.0.0.0";
    string ips = "";
    IPAddress address;
    if (IPAddress.TryParse(input, out address))
    {
        switch (address.AddressFamily)
        {
            case System.Net.Sockets.AddressFamily.InterNetwork:
                // we have IPv4, map it to IPv6
                IPAddress ip = IPAddress.Parse(input).MapToIPv6();
                ips = ip.ToString();
                break;
            case System.Net.Sockets.AddressFamily.InterNetworkV6:
                // we have IPv6, leave it as is
                ips = input;
                break;
        }
    }
    

    To see for yourself, you can take a look at the Reference Source. From there you see that in your example the AddressFamily was InterNetworkV6 so the MapToIPv6 method just returns the IPAddress unchanged because there's nothing to change.

    public IPAddress MapToIPv6()
    {
        if (AddressFamily == AddressFamily.InterNetworkV6)
        {
            return this;
        }
    
        // ...
    }
    

提交回复
热议问题