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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:33:06+00:00 2026-05-25T00:33:06+00:00

Hi i have atask to develop the application with Nstimer and background process. I

  • 0

Hi i have atask to develop the application with Nstimer and background process.

I have already implement background process with timer. And it is excuting good.but i have problem when i minimize application first time at that time it is not running the background process. after minimizing application 3 to 4 times. After that it is working smoothly. i also display the code of background task and timer as follow.

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

    UIApplication*    app = [UIApplication sharedApplication];
    NSLog(@"Application enter in background");
    [NSTimer scheduledTimerWithTimeInterval:2.0f
                                     target:self
                                   selector:@selector(updateCounter:)
                                   userInfo:nil
                                    repeats:YES]; 
}

And My updateCounter method is as given follow:

    - (void)updateCounter:(NSTimer*)timer {

    NSString *id = [[UIDevice currentDevice] uniqueIdentifier];
    NSLog(@"uniqueid:%@",id);

    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    locationManager.distanceFilter = kCLDistanceFilterNone; 
    [locationManager startUpdatingLocation];

    CLLocation *location = [locationManager location];

    // Configure the new event with information from the location
    CLLocationCoordinate2D coordinate = [location coordinate];

    NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude]; 
    NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];

    NSLog(@"dLatitude : %@", latitude); 
    NSLog(@"dLongitude : %@",longitude);

}

Is their any problem related code Please help me to solve it.

  • 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-25T00:33:07+00:00Added an answer on May 25, 2026 at 12:33 am

    First of all: Timers won’t work as you expect when your app goes in background.
    (depends on the availability of the run loop and your timeout)

    From what i gather from your code, seems you like to have location update when the app is running in background. For this, you should check the guidelines from here:
    https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW24

    There are several ways to track the user’s location in the background,
    some of which do not actually involve running regularly in the
    background:

    • Applications can register for significant location changes.
      (Recommended) The significant-change location service offers a
      low-power way to receive location data and is highly recommended for
      applications that do not need high-precision location data. With this
      service, location updates are generated only when the user’s location
      changes significantly; thus, it is ideal for social applications or
      applications that provide the user with noncritical, location-relevant
      information. If the application is suspended when an update occurs,
      the system wakes it up in the background to handle the update. If the
      application starts this service and is then terminated, the system
      relaunches the application automatically when a new location becomes
      available. This service is available in iOS 4 and later, only on
      devices that contain a cellular radio.
    • Applications can continue to
      use the standard location services. Although not intended for running
      indefinitely in the background, the standard location services are
      available in all versions of iOS and provide the usual updates while
      the application is running, including while running in the background.
      However, updates stop as soon as the application is suspended or
      terminated, and new location updates do not cause the application to
      be woken up or relaunched. This type of service is appropriate when
      location data is used primarily when the application is in the
      foreground.
    • An application can declare itself as needing continuous
      background location updates. An application that needs regular
      location updates, both in the foreground and background, should add
      the UIBackgroundModes key to its Info.plist file and set the value of
      this key to an array containing the location string. This option is
      intended for applications that provide specific services, such as
      navigation services, that involve keeping the user informed of his or
      her location at all times. The presence of the key in the
      application’s Info.plist file tells the system that it should allow
      the application to run as needed in the background.

    You are encouraged
    to use the significant location change service or use the standard
    services sparingly. Location services require the active use of an iOS
    device’s onboard radio hardware. Running this hardware continuously
    can consume a significant amount of power. If your application does
    not need to provide precise and continuous location information to the
    user, it is best to use those services that minimize power
    consumption. Chief among these low-power services is the significant
    location change service introduced in iOS 4. This service provides
    periodic location updates and can even wake up a background
    application, or relaunch a terminated application, to deliver them.

    For applications that require more precise location data at regular
    intervals, such as navigation applications, you need to declare the
    application as a continuous background application. This option is
    available for applications that truly need it, but it is the least
    desirable option because it increases power usage considerably.

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

Sidebar

Related Questions

Here's a problem. Developers have some kind of a task (develop certain feature), which
I have a long-running process that must run every five minutes, but more than
I have a task to develop a rails application following the model for routing.
I have a task to develop the application, with the help of the SQL
I have a task to develop the application with map kit and web service
I have a task to develop the application related to address and access the
I have a task to develop the android application with local push notification. I
We have a web application which sometimes (quite rarely, several times a day) gives
I am quite new to web development and have a task to develop a
Im building a web application which is a process management app. Several different employee

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.