Re: Sleep Notification
Re: Sleep Notification
- Subject: Re: Sleep Notification
- From: Laurent Daudelin <email@hidden>
- Date: Tue, 15 Feb 2011 17:21:59 -0800
Gordon,
I use performSelector:withObject:afterDelay: (not exactly NSTimer but close, I would guess), but maybe they don't work exactly the same. I download from the Internet on a regular basis. I thought about those cases when the app is put to the background to sleep and all other situations depending on the user. I did some testing and, so far, I don't have to really make any exception when one of those situation occurs. If my app is put to the background and suspended, obviously, my performSelector:withObject:afterDelay: obviously don't fire. When the app is brought back to the foreground, they will fire if the delay I gave has elapsed. I haven't seen any problem so far. So, maybe your handling in your timer wrapper class of NSTimer is causing unnecessary problems? Just a wild guess. I have no idea what kind of comm links you keep opened, so I could be wrong...
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
Logiciels Nemesys Software email@hidden
On Feb 15, 2011, at 14:31, Gordon Apple wrote:
> In accordance with the rules, I suspend timers (I have my own suspendable
> timer wrapper class for NSTimer) and I terminate comm links when in the
> background. No problem. It works. I get notifications when it
> re-activates and can re-establish comm. Unfortunately, when the iPad screen
> goes down, so does the comm link, but there is no notification when it comes
> back up to allow re-initialzing the comm link, Bonjour, etc., and be able to
> reconnect from the other side.
>
> Currently, my instructions to the users, in such case, is to switch out the
> app, then switch back. That works, because then I get notification.
>
> Someone had a suggestion that I run a repeating 1 sec. timer and store
> current time. If it ever shows being more than, say 2 sec. behind, then
> that means it woke up, so reset the comm link. That might work.
>
>
> On 2/15/11 2:25 PM, "Matt Neuburg" <email@hidden> wrote:
>
>> On Sat, 12 Feb 2011 13:01:28 -0600, Gordon Apple <email@hidden> said:
>>> If it exists, could somebody point me to notifiers for sleep/wake in iOS?
>>>
>>> I have a comm link that goes down with sleep. I would like to bring it up
>>> again on wake (in case the user forgot to disable sleep). I'm already doing
>>> this for applicationWillEnterForeground, but that doesn't work for sleep.
>>
>> What is "sleep" in iOS? The user can lock the screen, but that might or might
>> not cause the device to sleep, depending on a zillion other factors. Many
>> things can continue happening in the background. The whole concept is a shaky
>> one.
>>
>> If your app is backgrounded, you'll be suspended (freeze-dried) and all your
>> code will come to a complete stop, unless you take certain special measure
>> that qualify you for prevention of this (e.g. you're producing background
>> audio). In that case you'll get applicationWillEnterForeground when coming
>> back to the front.
>>
>> If the screen is locked and your app was in the background, it was already
>> suspended and you're covered.
>>
>> If the question is "How can I cover the case where the screen was locked and
>> is now being unlocked and my app is *frontmost*", that is your app becoming
>> *active*. Basically for long continuous activities you should pause when the
>> app becomes inactive and resume when the app becomes active again. Indeed, you
>> will also get the active notification when entering the foreground, so it is a
>> very good all-around place to cover resuming from interruptions of any kind.
>> m.
>>
>> --
>> matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
>> A fool + a tool + an autorelease pool = cool!
>> AppleScript: the Definitive Guide - Second Edition!
>> http://www.apeth.net/matt/default.html#applescriptthings
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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