1

Can anyone tell me that Is it possible to run some tasks when app is closed? Is there any service?

When app get closed I want run timer after every 10 minutes. When user change location, wanted to get latitude and longitude and if difference between old location and new location is greater than 50 than want to call web service. If I get response true than wanted to give notification that breweries found near your location.

I have tried in applicationWillTerminate method but this method is not called. I have searched for similar questions but nothing helped me.

Please tell me if it is possible than How to do this??

Gajendra K Chauhan
  • 3,387
  • 7
  • 40
  • 55
Nisha
  • 354
  • 2
  • 19
  • You can use location services exactly for this purpose. – Yunus Eren Güzel Jul 11 '14 at 06:02
  • @exculuber can you tell me in detail about that service? and how to do that is there any link?? – Nisha Jul 11 '14 at 06:05
  • 2
    possible duplicate of [Running background services in iOS](http://stackoverflow.com/questions/11417837/running-background-services-in-ios) – Ryan Jul 11 '14 at 06:14
  • https://developer.apple.com/library/ios/documentation/userexperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html Read the title "Starting the Significant-Change Location Service" – Yunus Eren Güzel Jul 11 '14 at 06:15
  • @exculuber startMonitoringSignificantLocationChanges will give me location updates even if app is closed? – Nisha Jul 11 '14 at 06:48
  • read the whole document you can see deferring from the background – Yunus Eren Güzel Jul 11 '14 at 07:00
  • @exculuber when i try to use [locationmanager allowDeferredLocationUpdatesUntilTraveled:distance timeout:(NSTimeInterval)10]; in didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation method, it is giving me error Assertion failure in -[CLLocationManager allowDeferredLocationUpdatesUntilTraveled:timeout:] 2014-07-14 12:18:57.312 BreweryAlerts[1739:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Delegate must respond to locationManager:didUpdateLocations:' – Nisha Jul 14 '14 at 07:13
  • @trick14 may be that it is duplicate but i do not get any solution from that and not in this. if you know than please help me – Nisha Jul 14 '14 at 09:24
  • @exculuber is it possible to get location when app is terminated by user?? – Nisha Jul 14 '14 at 12:32
  • 1
    As far as I know, if an app is terminated by user, it will never be executed in background until a launch by user. – Yunus Eren Güzel Jul 15 '14 at 06:32

1 Answers1

-1

Take a look at Background Execution and Multitasking, apple's documentation. It will help you, Here's the link [https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/][1]

DevdDexter
  • 63
  • 8