Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 28, 2013, 07:30 PM   #1
RookieAppler
macrumors member
 
Join Date: Mar 2012
Use cell connection if Wifi not available in iOS.

Code:
wifiReach = [ITMReachability reachabilityForLocalWiFi];
	[wifiReach startNotifier];
	
	NetworkStatus netStatus = [wifiReach currentReachabilityStatus];
    BOOL connectionRequired= [wifiReach connectionRequired];

switch (netStatus)
    {
        case NotReachable:
        {
            statusString = @"Access Not Available";
            connectionRequired= NO;
            break;
        }
            
        case ReachableViaWWAN:
        {
			NSLog(@"WWAN is reachable");
			wifiAvailable = YES;
            statusString = @"Reachable WWAN";
			UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Yes Reachable Login"
															message:@"Please enter the correct login details."
														   delegate:nil
												  cancelButtonTitle:@"OK"
												  otherButtonTitles:nil, nil];
			[alert show]
			;            break;
        }
        case ReachableViaWiFi:
        {
		
			wifiAvailable = YES;
			statusString= @"Reachable WiFi";
            break;
		}
    }
I have a login screen. On entering username and password app should check for WIFI/Cell and launch a web service. But on the device, when i turn off WiFi on purpose and try to use cell, it wont go ahead. I am stuck at login screen. How should i let my app work on cell(4g) as well.?If you need more info, please ask.Thanks

Last edited by robbieduncan; Jan 29, 2013 at 04:17 AM. Reason: Fix code tag
RookieAppler is offline   0 Reply With Quote
Old Jan 28, 2013, 07:38 PM   #2
KoolStar
macrumors Demi-God
 
KoolStar's Avatar
 
Join Date: Oct 2006
Location: Kentucky
Send a message via AIM to KoolStar Send a message via Skype™ to KoolStar
Your code only checks for wwan which is wifi you need to check for a host traceability instead on the other interface.
KoolStar is offline   0 Reply With Quote
Old Jan 28, 2013, 07:41 PM   #3
RookieAppler
Thread Starter
macrumors member
 
Join Date: Mar 2012
@KoolStar. How do i do that? Can you give me an example.
RookieAppler is offline   0 Reply With Quote
Old Jan 28, 2013, 08:58 PM   #4
KoolStar
macrumors Demi-God
 
KoolStar's Avatar
 
Join Date: Oct 2006
Location: Kentucky
Send a message via AIM to KoolStar Send a message via Skype™ to KoolStar
Apples guide to reachability.

Link: http://developer.apple.com/library/i...ion/Intro.html
__________________
"Innovation distinguishes between a leader and a follower." : S.J.
KoolStar is offline   0 Reply With Quote
Old Jan 29, 2013, 08:17 AM   #5
waterskier2007
macrumors 68000
 
waterskier2007's Avatar
 
Join Date: Jun 2007
Location: White Lake, MI
Send a message via AIM to waterskier2007
Why are you specifically checking reachability for wifi. Why not use reachabilityForInternetConnection or reachabilityWithHostName if you need to check a particular host address

edit: for example, instead of

Code:
wifiReach = [ITMReachability reachabilityForLocalWiFi];
try

Code:
wifiReach = [ITMReachability reachabilityForInternetConnection];
Now, obviously you would maybe want to change the name of that to something other than wifiReach, but you get the idea
__________________
2012 Mac Mini, 2.6 GHz, 16GB RAM, 1TB HDD
2.4Ghz 15" Macbook Pro
16 GB iPhone 5 : 32 GB iPhone 4S : 16 GB iPad 3
16 GB Nexus 7 (2012)
waterskier2007 is offline   1 Reply With Quote
Old Jan 29, 2013, 11:04 AM   #6
RookieAppler
Thread Starter
macrumors member
 
Join Date: Mar 2012
@waterskier2007. Thanks. That solved my problem.
RookieAppler is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Tags
cellular, error, ios, reachability, wifi

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPad: 16gb cell or 32gb wifi only isephmusic iPad 5 Nov 1, 2013 11:37 AM
Timemachine, moving from direct connection to WiFi connection jensvium Mac Peripherals 2 Oct 7, 2013 09:05 PM
iPad: No Tetherme USB connection, Wifi connection is fine labear Jailbreaks and iOS Hacks 0 Jun 16, 2013 04:12 PM
WIFI issues cant play games over WIFI only cell data wastingtime555 iOS 6 0 Nov 21, 2012 03:02 PM
Losing Cell Data Connection Coming Off Wifi rayward iPhone Tips, Help and Troubleshooting 1 Sep 20, 2012 02:21 PM

Forum Jump

All times are GMT -5. The time now is 05:41 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC