Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

App run in background iOS4.1

MixsiahMixsiah Posts: 12Registered Users
Hi Guys,


I have an app that reloads/refresh rss data every 10 seconds. When I hit the home screen, I want it to continue running in the background.

Also the BadgeIcon needs to be updated after every refresh indicating the number of new RSS data.

on the info.plist there is a property that says "Application is background only"
and then i enabled the checkbox next to it.


Is this the correct way to keep the app running in the background/multitask?
Post edited by Mixsiah on

Replies

  • cribasoftcribasoft Posts: 159Registered Users
    This is not possible. Only audio, location, and voice-over-IP services can run in the background.

    For what you are trying to do, the closest thing would be Push Notification services -- but that will pop-up an alert to the user, which will not provide the seamless experience you describe (badge numbers increasing in the background).
  • MixsiahMixsiah Posts: 12Registered Users
    cribasoft;245153 said:
    This is not possible. Only audio, location, and voice-over-IP services can run in the background.

    For what you are trying to do, the closest thing would be Push Notification services -- but that will pop-up an alert to the user, which will not provide the seamless experience you describe (badge numbers increasing in the background).
    Ok let's forget about the badge, I just need to reloadData:

    this is what I've done so far:'

    RootViewController.h
    - (void)switchToBackgroundMode:(BOOL)background;

    RootViewController.m

    - (void)switchToBackgroundMode:(BOOL)background
    {

    if([blogEntries count] == 0) {
    [self refreshData];
    }

    reloadTimer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(refreshData) userInfo:nil repeats:YES];
    }


    AppDelegate.m

    - (void)applicationDidEnterBackground:(UIApplication *)application {

    RootViewController *mainViewController = (RootViewController *)self.navigationController.visibleViewController;
    [mainViewController switchToBackgroundMode:YES];

    }



    Am i missing something here? I copied all this from the Breadcrumb App from the iOs sample codes
  • JasonRJasonR Posts: 1,588Super Moderators
    The best you can do is to start a background task, which will allow you to keep updating for up to 10 minutes after the user presses the home button. The iOS Application Programming Guide has the sample code to get you started. This post from Dr. Touch does a good job of explaining how it works:

    Understanding iOS 4 Backgrounding and Delegate Messaging @ Dr. Touch
    My development blog: http://jrinn.com
  • WhackoWhacko Posts: 3New Users
    You can add a badgenumber by using UILocalNotifications. Or by just setting the applicationIconBadgeNumber in your UIApplication.

    And also you can setup timers (like the clock app does) so that your app is fired up after a set interval. (don't set it to 10 seconds, but make it longer).
  • drewbertdrewbert Posts: 14Registered Users
    Whacko;245793 said:

    And also you can setup timers (like the clock app does) so that your app is fired up after a set interval. (don't set it to 10 seconds, but make it longer).
    So those timers will force an App to reopen? What if you're within another app?
Sign In or Register to comment.