Help with App Store rules, network alert issue

Discussion in 'iOS Development' started by abotsch31, Jun 22, 2009.

  1. abotsch31

    abotsch31 Banned

    Joined:
    Feb 9, 2009
    Messages:
    31
    Likes Received:
    0
    Hi,
    I recently submitted an application to the app store and got back an email saying this...

    "When the device is not connected to a network, your application does not load its contents and stays blank. This behavior might lead to user confusion. It would be appropriate to display either a notification or an alert stating that internet connectivity is required."

    Does anyone know of any really good tutorials that tell how to implement this action, or better yet, does anyone know how I would go about this.
  2. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Well, i had the easy solution posted, but then i realized you made this thread again ten minutes later (This thread was #2), because no one answered.

    Aww, that sucks.
  3. bamhm182

    bamhm182 Member

    Joined:
    Mar 2, 2009
    Messages:
    544
    Likes Received:
    0
    Device:
    3G iPod touch
    I'm not familiar with the internet on the iPhone/iPod, but I'm assuming it would be something like this:

    Code:
    - (void)viewDidLoad
    {
    if(![Something to check if it is connected to the internet])
    {
    UIAlertView *alertView = [[UIAlertView alloc]
    initWithTitle:@"No internet connection."
    message:@"No internet connection is available. Connect to the internet and try again."
    delegate:self
    cancelButtonTitle:nil
    otherButtonTitles:@"Okay", nil];
    [alertView show];
    [alertView release];
    }
    }
    Notice the ! in the if statement, this tells it to check for the opposite, so in this case, you'll want it to check if it is not connected to the internet, hence the need for the !.
  4. wearmaize

    wearmaize Active Member

    Joined:
    Feb 13, 2008
    Messages:
    2,442
    Likes Received:
    13
    Device:
    iPhone 4S (Black)
    You can just create an alert to show when the app opens:

    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    	
    	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Notice" message:@"All tabs will be blank without an Internet connection.  The Support button will load my website in Safari and will quit this app." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Support",nil];
    	[alert show];
    	[alert release];
    
  5. jamil_d

    jamil_d Active Member

    Joined:
    Dec 15, 2007
    Messages:
    2,041
    Likes Received:
    12
    Device:
    iPhone 3GS (Black)
    Try:
    Code:
    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
            // Do stuff here
    }
    
  6. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    That would only work if he were to be using a UIWebView, which he is not.
  7. abotsch31

    abotsch31 Banned

    Joined:
    Feb 9, 2009
    Messages:
    31
    Likes Received:
    0
    Hey, actually, I am using a webview, so that should work, so I tried putting in...

    Code:
    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error 
    {
    	UIAlertView *alertView = [[UIAlertView alloc]
    							  initWithTitle:@"No internet connection."
    							  message:@"In order to use this app, you must be connected to the internet via wifi or your cellular network."
    							  delegate:self
    							  cancelButtonTitle:nil
    							  otherButtonTitles:@"Okay", nil];
    	[alertView show];
    [alertView release];
    }

    But nothing happened when I tried it and turned off my internet, does anybody see any problems.
  8. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Which view/view controller are you using your UIWebView in? If it's not in the first it isn't going to work.
  9. abotsch31

    abotsch31 Banned

    Joined:
    Feb 9, 2009
    Messages:
    31
    Likes Received:
    0
    Yes, I put it in the controller.m of the first webview that would load when the app opens up.
  10. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Make sure the webview's delegate is set to whatever has that method.

Share This Page