First App installation-Problems with authorized network access, first app Installation

Source: Internet
Author: User

First App installation-Problems with authorized network access, first app Installation
App installation for the first time-pitfalls for authorizing network access 1. What is this pop-up box?

.. Picture

2. How to trigger

1. First, you have to have an iPhone of the China line version.
2. The system version is later than iOS10.
3. When an App is installed for the first time, network switching is triggered as long as the App performs network requests.

3. Does it play every time? How can I reinstall the App after uninstalling it?

This dialog box is triggered only when the App is installed for the first time and a network request is triggered. in addition, the user will be given a clear network permission status (wifi/wifi + 4g3g2g/notNetwork) for the App, otherwise the pop-up box will not disappear.

Problems encountered in the project and solutions 1. the project encountered a special problem. AFN was not used first, but it does not matter. data Loading and startup of the Project App must be performed before login. at first, these network switches were placed in In didfinishlaunchingwitexceptions.
This will lead to a pitfall. At this time, the Window does not have rootcontroller, so even if the system pop-up box is triggered, sometimes the pop-up box may appear after the App is closed. the second pitfall: because Apple does not have an API for requesting network permissions. therefore, we cannot obtain the user's clicking result. Are users allowed or not allowed. generally, the user's authorization can only be determined by constantly checking the network.
2. solution (how to avoid embarrassment elegantly)

Knock on the blackboard
First, before real data loading/network switching. use the timer to continuously initiate network detection. data interaction is performed only when the user is authorized and the network connection is detected again.
If the network is not connected (There are pitfalls,AFN/Reachability for network detection,However, the problem is that before the user decides to authorize, The results returned by the detection do not have a network. Unlike the enumeration of camera/album permissions, there is a pending status.), So that the timer continues to initiate network detection.

The problem arises:
After the user does not allow network behavior, AFN/Reachability still returns the result of no network connection.

Solution:

Here, before the timer, You need to customize a prompt box, which will inevitably pop up. the pop-up box is used to prompt the user and guide the user to redirect settings to solve the network problem on their own.
After the user selects the authorization or denied authorization option, the system checks the network connection status. If the connection is established, the system interacts with the data and removes the custom pop-up box. If the user refuses to grant permissions, the pop-up box is displayed.

Note: The pop-up box of the China Mobile Phone System will inevitably cover all the pop-up boxes.

// NetWork status pre-judgment netWork = [[SDNetwork alloc] init]; netWorkType = [netWork integerWithNetworkType];/** the first time the netWork status is returned, pop up the custom prompt-(to avoid misunderstanding due to the inability to detect the network and no interaction) * The first network status is returned, or the China Bank's mobile phone network permission causes no network or the user's flight mode/or the user has proactively disabled the Network * a friendly prompt is displayed, prompting the user to try to solve the network problem. * When the App is installed for the first time, the pop-up will be blocked by the dialog box asking the mobile phone permission of China Bank. After the user decides whether the App uses the network, then guide the user to set */if (netWorkType = 0) {// guide the user to system settings [[SDAlertView using alert] showDialog: @ "No network connection" message: @ "1. check whether the flight mode is triggered. If the flight mode is disabled, Run \ n \ n2. check whether the network permission is disabled. Authorize sentapr to access the network and perform the following operations (set-cellular mobile network-sentebao) "leftBtnString: @" Exit sentapr "rightBtnString: @" set "leftBlock: ^ {[Tool exitApplication: self];} rightBlock: ^ {[Tool openUrl: [NSURL URLWithString: UIApplicationOpenSettingsURLString]; [Tool exitApplication: self];} // timer = [nst1_timerwithtimeinterval: 1.f target: self selector: @ selector (netWorkRequest) userInfo: nil repeats: YES]; [[nsunloop currentRunLoop] addTimer: timer forMode: nsunloopcommonmodes];}-(void) netWorkRequest {/** Check network status-No Network * continue to execute timer */if (netWorkType = 0) {NSLog (@ "No network/pending, continue detection "); netWorkType = [netWork integerWithNetworkType];} /** detect network status-network available * timer stop * Hide the pop-up @ "No network connection" prompt box * execute large Loading */else {if (timer) {[timer invalidate]; timer = nil; [[SDAlertView inclualert] hideDialogAnimation: NO]; NSLog (@ "a network is detected and large Loading is executed "); dispatch_async (dispatch_get_global_queue (DISPATCH_TARGET_QUEUE_DEFAULT, 0), ^ {[self BigLoading] ;}}) ;}}

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.