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 7172203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:34:08+00:00 2026-05-28T15:34:08+00:00

Searching for an answer, some had noted the issue but no one resolved it.

  • 0

Searching for an answer, some had noted the issue but no one resolved it. I simply want to the user to be notified if a network connection change has occurred (ie loss of network). The code below works but I get multiple alerts, usually 3. I understand the reason why it may happen because of multiple internal calls being made for accuracy but I can’t seem to have only one alert display and that’s that. I’ve tried to use a BOOL to detect if an alert is already showing (alertshowing) but it still doesn’t help.
Thanks for your thoughts.

- (void)applicationDidBecomeActive:(UIApplication *)application {
    ////NSLog(@"DidBecomeActive");

    [self performSelector:@selector(getNetworkConnection) withObject:nil afterDelay:5.0];

}


-(void)getNetworkConnection
{
    Reachability *r = [Reachability reachabilityWithHostName:@"www.google.com"];

    NetworkStatus internetStatus = [r currentReachabilityStatus];

        if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN))
        {
            if (!self.alertShowing) {
            UIAlertView *myAlert = [[[UIAlertView alloc] initWithTitle:@"No Internet Connection" message:@"This app require an internet connection via WiFi or cellular network to work." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil] autorelease];
            self.alertShowing = YES;
            [myAlert show];
            }
        }       
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    self.alertShowing = NO;
}
  • 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-05-28T15:34:09+00:00Added an answer on May 28, 2026 at 3:34 pm
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNetworkChange:) name:kReachabilityChangedNotification object:nil];
    

    The above line of code should only be called a single time for the entire app.
    If you invoke this line of code in a function which is called many times, the notification also shows many alerts.

    So I recommend you to create a singleton class which will be live throughout the app and call the above line of code in the area where object for singleton class is created.

    Note:- above line of code should be invoked only once for the entire app

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've done some searching for the answer, but only find a lot of PHP
I have been searching everywhere but I could not find an answer. I need
I have been searching around using Google but I can't find an answer to
I've spent the past few hours searching, but can't seem to find the answer.
Ok, I have tried searching around for this answer, but with no luck. I
After much searching the answer seems to be no, but I thought I'd ask
Okay guys, I've got one thats got me baffled. I've done some searching for
In searching for an answer to an interesting situation which I had recently encountered
From last 2 weeks I am searching for an answer but not getting a
Got a partial answer from searching in this thread: Viewing raw RSS feed? But

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.