Network error while switching from WiFi to 3G

2019-08-27 06:56发布

My iPhone app is web based.It works fine while running in WiFi and in 3G But the problem is when I run the app on WiFi and minimize it,and turn off the WiFi and switch to 3G-it shows no network.

In user's case-when they use the app under WiFi and goes out it failed to connect with 3G network.I am using apple's Reachability class to check the network connection Anybody please tell any solution

Do i code something to reconnect if the connection lost or switch from WiFi to 3G ?

1条回答
放荡不羁爱自由
2楼-- · 2019-08-27 07:23

You can use connection:didFailWithError: and implement into your method to reconnect your user.

Like this

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    [self reconnect];
}

- (void)reconnect
{
   //reconnect your user
}

I hope it can help you ! ;)

查看更多
登录 后发表回答