I need to return to my app after making a call from my app, so I use this code:
NSURL *url = [NSURL URLWithString:@\"telprompt://123-4567-890\"];
[[UIApplic
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(suspended:) name:@"UIApplicationSuspendedNotification" object:nil];
The above code by @J Saprio works absolutely fine. Before it suspends the Application NSNotificationCenter
call UIApplicationSuspendedNotification
. Once you click the "call" it will execute the (suspended:)
method. Here the catch is, every time you call NSNotificationCenter
method it will give a call to (suspended:)
with the increment of one. Solution is to remove the observer for NSNotificationCenter
. Following is the snippet for it. It will help you to execute the following method only once.
-(void)suspended:(NSNotification *) notification
{
NSLog(@"Suspended");
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"UIApplicationSuspendedNotification" object:nil];
}