Re: iOS firing an event in the future when an app is in the background
Re: iOS firing an event in the future when an app is in the background
- Subject: Re: iOS firing an event in the future when an app is in the background
- From: Roland King <email@hidden>
- Date: Thu, 07 May 2015 00:31:19 +0800
> On 7 May 2015, at 00:08, Alex Zavatone <email@hidden> wrote:
>
> iOS 7/8, Xcode 6.2
>
> I'm looking into performing an event in the future on iOS very likely when the app may be in the background, possibly up to 24 hours in the future.
>
> I'm looking at using an NSTimer, performSelectorAfterDelay, or GDC's dispatch_after.
>
> Looking at all the caveats for background modes, I'm not sure the best path to proceed that will waste the least of my time in getting this to work reliably.
>
> The requirement is to call one selector with one NSString parameter.
>
> If the app is getting CLLocation updates in the background, is it safer to manually perform a check within locationManager:didUpdateLocations even n seconds than to expect a background event to fire up to 24 hours in the future?
>
> Thanks in advance,
> Alex Zavatone
Not wishing to waste your time. There is no background mode which gives you NSTimer or dispatch_after() firings when backgrounded. This is why writing standalone alarmclock apps in iOS isn’t really possible. If you want someone to be alerted at a given time, set a notification to alert them at that time. If you want to check when the app comes back in the foreground that they should know something happened, check it then. If you want to check something at a given time and decide whether or not to alert .. I think you are SOL.
If you are getting CLLocation updates and the randomness of those is fine enough grained to do what you want, use that, be aware that using background location is subject to app review and the primary use of background location must be because you need location in the background. I suspect in your case it is.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden