[CoreTelephony]Call API

Discussion in 'iOS Development' started by Jeepston, Jan 12, 2010.

  1. Jeepston

    Jeepston New Member

    Joined:
    May 17, 2009
    Messages:
    45
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    continuing topic of collecting core telephony functions... This time it will be Call APIs (at least that part that I've got somehow working

    Please Register or Log in to view images

    )

    During the phone call a bunch of notifications are thrown:

    kCTCallStatusChangeNotification -- I'm not sure when it is thrown, but I think that at the very moment of the incoming call (sometimes it is not possible to extract info about caller at this moment)

    kCTCallIdentificationChangeNotification -- is thrown when call is identified. Here, you can get caller ID and\or disconnect the call:

    [objc]
    static void callback_call(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
    {
    NSDictionary *info = (NSDictionary *)userInfo;
    CTCall *call = (CTCall *)[info objectForKey

    Please Register or Log in to view images

    "kCTCall"];
    NSString *caller = CTCallCopyAddress(NULL, call);
    CTCallDisconnect(call);
    /* or one of the following functions: CTCallAnswer
    CTCallAnswerEndingActive
    CTCallAnswerEndingAllOthers
    CTCallAnswerEndingHeld
    */
    }
    [/objc]

    kCTCallHistoryRecordAddNotification -- thrown when the record about the call is added to call_hostory.db.


    SpringBoard also has a couple of functions called during the call:

    HOOK(SBCallAlert, initWithCall$, id, struct __CTCall *call) may be used to prevent call info alert from appearing (if you need to cancel a call).


    Problems, that remain open (for me):
    1. Cancel call alert while device is locked (there is function addCall in SBAwayModel, but I don't completely understand how and when it is invoked. If I hook into it and try to cancel call alert, it will show up for a second anyway...)

    2. Phone icon badge: set the correct badge after deleting record from call history DB.

    Does anyone have any suggestions how to solve those problems?..
  2. aleksandyr

    aleksandyr New Member

    Joined:
    Jan 25, 2010
    Messages:
    5
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    http://blogs.oreilly.com/iphone/2008/04/open-iphone-sdk-adding-applica.html looks like it will be useful for making calls to update badge counts.

    I'm trying to follow along (I want to build a simple auto-answer whitelist) but I can't seem to get the various CTCall... functions to link.

    extern NSString *CTCallCopyAddress(CFAllocatorRef alloc, __CTCall const *call);
    extern NSString *CTCallCopyName(CFAllocatorRef alloc, __CTCall const *call);

    Where am I going astray?

    Thanks,

    Alex
  3. Jeepston

    Jeepston New Member

    Joined:
    May 17, 2009
    Messages:
    45
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
  4. aleksandyr

    aleksandyr New Member

    Joined:
    Jan 25, 2010
    Messages:
    5
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Still can't get your demo code to work... Seriot's headers and my own classdumps have no references to CTCallCopy*.

    Help?
  5. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    Class-dump only extracts Obj-C code, and CoreTelephony is AFAIK CoreFoundation-type C. I haven't yet heard of a tool that can do this to C Mach-O executables without being overly expensive/complicated.
  6. aleksandyr

    aleksandyr New Member

    Joined:
    Jan 25, 2010
    Messages:
    5
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Ok then: what's the source of these headers? Heck, what's the appropriate method signature?
  7. Jeepston

    Jeepston New Member

    Joined:
    May 17, 2009
    Messages:
    45
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Code:
    typedef struct __CTCall CTCall;
    extern NSString *CTCallCopyAddress(void*, CTCall *);
    I was never able to get CTCallCopyName to work...
  8. roocell

    roocell New Member

    Joined:
    Feb 2, 2010
    Messages:
    3
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    Hey guys,
    I'm interested in calling these CoreTelephony functions.
    I found these from some otool output
    single module __CTCallHistoryStoreDataCountersGetAllReceived
    single module __CTCallHistoryStoreDataCountersGetAllTransmitted
    single module __CTCallHistoryStoreDataCountersGetLastReceived
    single module __CTCallHistoryStoreDataCountersGetLastResetTime
    single module __CTCallHistoryStoreDataCountersGetLastTransmitted
    single module __CTCallHistoryStoreDataCountersGetLifetimeReceived
    single module __CTCallHistoryStoreDataCountersGetLifetimeTransmitted

    I tried class-dump-z on CoreTelephony and didnt see much at all.
    I'm trying to get the same data that shows up in the settings "Cellular Network Usage". I'm fairly sure that one of the above function will produce those numbers, but I'm just not sure how to call them or use the CoreTelephony framework properly.

    Does anyone know how to call these functions ?
  9. Jeepston

    Jeepston New Member

    Joined:
    May 17, 2009
    Messages:
    45
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    AFAIR, this data is stored in call history db.
  10. roocell

    roocell New Member

    Joined:
    Feb 2, 2010
    Messages:
    3
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    Is there some other way to access the "call history db"?
    It appears to me that these functions may do that for me. I just have to figure out the proper way to use them (ie - arguments, return variables).
    I've tried CTPowerGetAirplaneMode() which is in the CoreTelephony otool dump here http://code.google.com/p/iphone-wireless/source/browse/wiki/CoreTelephonyFunctions.wiki
    and it works fine.
    Any ideas on the proper usage of the _CTCallHistoryStoreDataCountersGetAllReceived() function ?
    ------------------double post merged------------------
    i found this.
    http://code.google.com/p/iphonelogd/wiki/CallHistoryDatabase
    i'll give it a shot.
    ------------------double post merged------------------
    but i'm trying to do this without jailbreaking.
    after some investigation (even if I could write the SQL code to read the CallHistoryDB), my app wouldnt be able to access it because it's outside of the app's sandbox.
    hmmm....perhaps my calls to _CTCallHistoryStoreDataCountersGetAllReceived() try to get info out of the DB and my app cant do it because it's outside the sandbox.....darn.

Share This Page