AJ.
AJ.

Reputation: 1463

Is there a way to get to know if the user is on call while using my app?

Is it possible to identify whether the user is on a phone call while using an app.

Here is the scenario:

  1. I get a call
  2. I accept the call
  3. Tap the home button
  4. Launch an app

At this point can I tell this app that a call is going on in background?

Getting to know the screen is not a full blown option. Because it makes life difficult when on internet tethering.

Upvotes: 4

Views: 376

Answers (3)

pixel
pixel

Reputation: 5298

To elaborate on what Ben said, you'll want to subtract [UIApplication sharedApplication].statusBarFrame from the height you set your View to.

Upvotes: 1

Ben S
Ben S

Reputation: 69412

There isn't a public API for any phone state or functionality, so you'll have to rely on side-effects of being on a call.

You can either check the status bar like Ben Gottlieb suggested, or you can try to initialize an audio recording, if it fails with an error of already in use, you can be fairly certain the microphone is being used for a call.

Upvotes: 1

Ben Gottlieb
Ben Gottlieb

Reputation: 85542

You could check the height of the status bar. If it's more than 20px, you're either on a call, or tethering (which is not supported on AT&T, so it must be on a call if you're in the US).

[UIApplication sharedApplication].statusBarFrame

Upvotes: 1

Related Questions