Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: How to tell when an app is going to suspend? [duplicate]

I want to know when my app is going to be suspend? The state of not being active for a certain amount of time or being terminated by the user. I need this because I need to close a connection a web socket. I want to keep the connection alive while the app is in the background state though.

How do I do this?

Thanks

like image 739
Jason Silberman Avatar asked Dec 13 '13 06:12

Jason Silberman


1 Answers

You can also add Notification observer

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(receiveSuspendNotification:)
                                             name:UIApplicationWillResignActiveNotification
                                           object:nil];

- (void) receiveSuspendNotification:(NSNotification*)notif
{
}

method will get called and you can perform the required tasks.

like image 198
Keshav Avatar answered Oct 20 '22 16:10

Keshav