Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7983953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:07:02+00:00 2026-06-04T11:07:02+00:00

i have developed a radio application which uses network connection for online streaming, and

  • 0

i have developed a radio application which uses network connection for online streaming, and also i am checking the condition whether network is available or not. if no network connection, it shows an alert “their is no network available” .my code is here

 - (void)viewDidLoad
  {
  [super viewDidLoad];


  //checking network reachability statys, this will show one alert view if no network available
    Reachability* reachabile = [Reachability reachabilityWithHostName:@"www.apple.com"];
    NetworkStatus remoteHostStatus = [reachabile currentReachabilityStatus];

   if(remoteHostStatus == NotReachable) 
    {

    NSLog(@"not reachable");
       UIAlertView *notReachableAlert1=[[UIAlertView alloc]initWithTitle:@"NO INTERNET  CONNECTION" message:@"This Application Need Internet To Run" delegate:self cancelButtonTitle:@"Okay Buddy" otherButtonTitles:nil];
    notReachableAlert1.delegate=self;
     [notReachableAlert1 show];
     [notReachableAlert1 release];


    }




    [[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(moviePlayerPlaybackStateDidChange:) 
                                             name:MPMoviePlayerPlaybackStateDidChangeNotification 
                                           object:nil];




    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:player];



    // Do any additional setup after loading the view from its nib.
  }

also i checked the condition on notifications

  -(void) moviePlayerPlaybackStateDidChange:(NSNotification*)notification 
  {
  Reachability* reachabile = [Reachability reachabilityWithHostName:@"www.apple.com"];
  NetworkStatus remoteHostStatus = [reachabile currentReachabilityStatus];

  NSLog(@"playbackDidChanged");

  MPMoviePlayerController *moviePlayer = notification.object;
  player=notification.object;
  MPMoviePlaybackState playbackState = moviePlayer.playbackState;
   if(playbackState == MPMoviePlaybackStateStopped) 
     {
      NSLog(@"MPMoviePlaybackStateStopped");


   }
   else if(playbackState == MPMoviePlaybackStatePlaying) {
    NSLog(@"MPMoviePlaybackStatePlaying");


} else if(playbackState == MPMoviePlaybackStatePaused) {
    NSLog(@"MPMoviePlaybackStatePaused");

    if(remoteHostStatus == NotReachable) 
    {

          NSLog(@"not reachable");
          UIAlertView *notReachableAlert1=[[UIAlertView alloc]initWithTitle:@"NO INTERNET CONNECTION" message:@"This Application Need Internet To Run" delegate:self cancelButtonTitle:@"Okay Buddy" otherButtonTitles:nil];
        notReachableAlert1.delegate=self;
        [notReachableAlert1 show];
        [notReachableAlert1 release];


      }
 } else if(playbackState == MPMoviePlaybackStateInterrupted) 
    {
    NSLog(@"MPMoviePlaybackStateInterrupted");

    if((remoteHostStatus == NotReachable)&&(remoteHostStatus != ReachableViaWiFi)) 
    {

          NSLog(@"not reachable");
          UIAlertView *notReachableAlert1=[[UIAlertView alloc]initWithTitle:@"NO INTERNET CONNECTION" message:@"This Application Need Internet To Run" delegate:self cancelButtonTitle:@"Okay Buddy" otherButtonTitles:nil];
        notReachableAlert1.delegate=self;
        [notReachableAlert1 show];
        [notReachableAlert1 release];


     }

my problem is, when app goes out of range from wifi connection without without 3g and normal data connection, it freezes for some time. and when i came back to range only it goes to active state and shows alert.

is their anything wrong i did with network availability checking?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:07:03+00:00Added an answer on June 4, 2026 at 11:07 am

    this is sample u can edit based on ur application

    @class Reachability;
    
    @interface urAppDelegate : NSObject <UIApplicationDelegate> 
    {
    
            Reachability* internetReachable;
    
            Reachability* hostReachable;
    
            BOOL   hostActive;
    
            BOOL   internetActive; 
    
    }
    
    @property (nonatomic, assign) BOOL hostActive;
    
    @property (nonatomic, assign) BOOL internetActive;
    @end
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    
        self.internetActive=NO;
        self.hostActive=NO;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
    
        internetReachable = [[Reachability reachabilityForInternetConnection] retain];
        [internetReachable startNotifier];
    
        // check if a pathway to a random host exists
        hostReachable = [[Reachability reachabilityWithHostName: @"www.apple.com"] retain];
        [hostReachable startNotifier];
    
        // now patiently wait for the notification
    
     [self.window makeKeyAndVisible];
        return YES;
    }
    
    -(void) checkNetworkStatus:(NSNotification *)notice{
        NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
    
        switch (internetStatus)
        {
            case NotReachable:
            {
                NSLog(@"The internet is down.");
                self.internetActive = NO;            
                break;
            }
            case ReachableViaWiFi:
            {
                NSLog(@"The internet is working via WIFI.");
                self.internetActive = YES;
    
                break;
            }
            case ReachableViaWWAN:
            {
                NSLog(@"The internet is working via WWAN.");
                self.internetActive = YES;            
                break;
            }
        }
    
        NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
        switch (hostStatus)
        {
            case NotReachable:
            {
                NSLog(@"A gateway to the host server is down.");
                self.hostActive = NO;            
                break;
            }
            case ReachableViaWiFi:
            {
                NSLog(@"A gateway to the host server is working via WIFI.");
                self.hostActive = YES;
    
                break;
            }
            case ReachableViaWWAN:
            {
                NSLog(@"A gateway to the host server is working via WWAN.");
                self.hostActive = YES;
                break;
            }
        }
    
    
        if (internetActive && hostActive)
        {       
            // Net work Available.......
    
        }
        else
        {
            UIAlertView *netWorkAlert=[[UIAlertView alloc]initWithTitle:@"Network Connection Error" message:@"Please Check Connection" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil, nil];
            [netWorkAlert show];
            [netWorkAlert release];
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed one application which will have activities and one background service and
I have developed a web application that uses the jQuery DateTimePicker by Trent Richardson
I have developed an AR application for iPad2 that uses an ImageMarker to display
Have developed an MVC3 application which monitors when users access static content on the
I have developed a multithreaded web application that runs in Tomcat. But I cannot
I have developed a PHP application that processes relatively large text files, and stores
I have developed some mysql queries for my application, and created indexes and used
I have developed chart rendering functionality in my web application and set following setting
I have developed a GUI application in NetBeans and I want to share it
I have developed an Android application targeting Android 2.2 now I want to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.