objective c mute UILocalNotification when user making phone call

412 Views Asked by At

I have an app that is registered for UILocalNotification, and the notification sound have a duration of 30 seconds, when user is making a phone call and the fireDate of the UILocalNotification at the same time with the call, the notification sound play in the headset and the user is not able to hear his voice call

im wondering if there is a way to mute the UILocalNotification if there is a running phone call

Thanks in advance.

1

There are 1 best solutions below

2
On

Use the CTCallCenter ( the Core Telephony framework ) to register an event handler so your app gets notified when a call starts

Use the CTCallCenter class to obtain a list of current cellular calls, and to respond to state changes for calls such as from a dialing state to a connected state. Such state changes are known as cellular call events.

Something like:

CTCallCenter *callCenter = [[CTCallCenter alloc] init];

...

...

callCenter.callEventHandler=^(CTCall* call)
{    
  if (call.callState == CTCallStateConnected) 
  {
    NSLog(@"Call has just been connected");
  }    
}