Search code examples
iphoneiosobjective-ccore-telephony

Invoking app in iOS after every phone call ends


I am trying to make an app, which should come into picture (each & every time) as soon as the user is done with his/her phone call.

Use case:

"My app" is currently not running.

  1. User Makes a phone call from mobile.
  2. Once the call is completed, "My app" should start/running.
  3. It should gather some information about last call.
  4. write it into log & ends..

I have seen tasks running in background foreground but how to invoke App after each phone call.

Thanks..


Solution

  • You cannot do this. Quite simply iOS does not (yet) have any such feature where your app would be triggered based on some system event.

    But you can explore some alternatives when a call comes when your app is running.


    If your app is running when the call comes

    It might be possible to sign up to receive notifications (using UINotificationCenter calls) from UITelephony.

    However, if you're actively using your app when the phone call starts, it will call -(void)applicationWillEnterForeground when the call is finished. As for differentiating a phone call end versus just a regular return to phone call, I don't know. But it's a start.

    If your application is running while a call is in place CoreTelephony Framework provides call states. CTCall class provides information about the call states. I have not used this myself but you may find it useful.

    extern NSString const *CTCallStateDialing;
    extern NSString const *CTCallStateIncoming;
    extern NSString const *CTCallStateConnected;
    extern NSString const *CTCallStateDisconnected;