IOS10 on the issue of Internet access for iphone in China

Source: Internet
Author: User

Install a new app on IOS10, the first time it opens asking the user "whether to allow app usage data" (a device that is country-only and needs to connect to a mobile network), as shown, the app is not networked until the user clicks Allow, which means that all network requests fail.

Ask the user "whether to allow app usage data" problem

The direct result of this problem is that the user enters the homepage is a blank, very unfriendly to the user. At present, many apps do not deal with this problem, require the user to manually refresh, of course, there are also better, such as adding a "view solution" and other buttons to tell users why this problem and the solution.

But as a developer, the feeling can not be tolerated, although the main reason may be that the function is too hasty so that Apple can not provide the corresponding API, but we should still try to solve.

Solutions

In fact, the method is very simple, using afnetworking can be done.

As we all know, AFN can monitor the network situation, when the first monitoring of the network is WiFi or mobile network when the user authorization is successful, this time sent a notice to let the homepage reload on it. (Not like, it is so simple)

As for this is not the first time, you can use the Keychain storage record (what?) you think it's too much trouble? Of course, you do not record, but it is not a big deal to request two times every time you start.

After testing, the user did not click Allow before, AFN monitoring the status of the network is afnetworkreachabilitystatusnotreachable, click Allow (if the cellular network is unobstructed), either WiFi or mobile network, so this scheme is feasible. Demo in here, poke me download

Some people say that the use of Coretelephony framework Ctcellulardata is also possible, you can test themselves.

Note

This scenario is only for the first time the app is installed. If the user is to update the app, then the first startup because the keychain did not get the corresponding information will be mistaken for the first installation, it will cause the home page data request two times, the personal feel little impact, because only this time will request two times. Finally, if you have a better plan to share it with (*^__^*)



Start in the Dark
Links: https://www.jianshu.com/p/4ad55f6878a0
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

IOS10 on the issue of Internet access for iphone in China

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.