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

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
    edited September 2010
    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
    edited September 2010
    cribasoft wrote: »
    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 San Diego, CAPosts: 1,587Registered Users
    edited September 2010
    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: <a href="http://jrinn.com" target="_blank">http://jrinn.com</a>;
  • WhackoWhacko Posts: 3New Users
    edited September 2010
    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
    edited October 2010
    Whacko wrote: »
    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.