简体   繁体   中英

Your app crashed on iPad and iPhone running iOS 11.1 connected to an IPv6 network when we:

我的应用程序在测试时,我的应用程序在IPad和Iphone上运行良好。我正在使用AFNetworking 2.0进行API的调用,并且由于IPv6网络,苹果应用程序的评论又一次又一次地拒绝了我的应用程序,我使用了硬编码的IP地址,例如http:// 192.230.66.71/XXXXXXXX/XX/我对此感到沮丧,请有人帮助我现在该怎么办。

You are not supposed to use hard code IP address according to the Apple's rule .

Don't Use IP Address Literals Make sure you aren't passing IPv4 address literals in dot notation to APIs such as getaddrinfo and SCNetworkReachabilityCreateWithName. Instead, use high-level network frameworks and address-agnostic versions of APIs, such as getaddrinfo and getnameinfo, and pass them hostnames or fully qualified domain names (FQDNs). See getaddrinfo(3) Mac OS X Developer Tools Manual Page and getnameinfo(3) Mac OS X Developer Tools Manual Page.

Note: In iOS 9 and OS X 10.11 and later, NSURLSession and CFNetwork automatically synthesize IPv6 addresses from IPv4 literals locally on devices operating on DNS64/NAT64 networks. However, you should still work to rid your code of IP address literals.

There are two things you should notice in my opinion:

1. Hard code IP address is not recommended, but according to the note above and the search I did that some developers pass the review with IPv4 address literals in their app.
So try not to use IPv4 address literals in your app first, then make sure you notice the second thing I mentioned following.

2. Your app could crash in other network related problems. Like what I comment before. I will paste it here to make things more clear to you.

Make sure you handle the received data safely. My app was rejected in same reason but I found the real problem is the received data could be server error under some circumstances, which is resulted in crashing the app. I pass the app review by fix that bug.

For example, the app works fine under your network, but it could failed in other place like connection too slow and resulted in timeout. In that case, you will get some server error data or empty data, then if you force unwrap data in your code, the app will crash. And In my case, Apple rejected my app with IPv6 issues, which is not the real problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM