user4963735
user4963735

Reputation: 1

call event in iphone using Core Telephony

I am trying to get call events in my iPhone app. For that I am trying to register to Core Telephony notification, but I am getting below error. I am testing this on iPhone 3GS.

Undefined symbols for architecture armv7:
  "CTTelephonyCenterGetDefault()", referenced from:
  -[CallEventAppDelegate application:didFinishLaunchingWithOptions:] in CallEventAppDelegate.o
ld: symbol(s) not found for architecture armv7

Here is my sample code:-

    void (*CTTelephonyCenterAddObserver) (id,id,CFNotificationCallback,NSString*,void*,int);

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
   {

// register for all Core Telephony notifications


id ct = CTTelephonyCenterGetDefault();

CTTelephonyCenterAddObserver(ct,   // center
                             NULL, // observer
                             telephonyEventCallback,  // callback
                             NULL,                    // event name (or all)
                             NULL,                    // object
                             CFNotificationSuspensionBehaviorDeliverImmediately);

return YES;
    }

 static void telephonyEventCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{

NSString *notifyname = (__bridge NSString*)name;
if ([notifyname isEqualToString:@"kCTCallIdentificationChangeNotification"])
{
    NSDictionary* info = (__bridge NSDictionary*)userInfo;
    //CTCall* call = (CTCall*)[[[info objectForKey:@"kCTCall"] stringValue] isEqualToString:@"4"];

    CTCall* call = (CTCall*)[info objectForKey:@"kCTCall"];

    //NSString* caller = CTCallCopyAddress(NULL, call);

    if (call.callState == CTCallStateDisconnected)
    {
        NSLog(@"Call has been disconnected");
    }
    else if (call.callState == CTCallStateConnected)
    {
        NSLog(@"Call has just been connected");
    }
    else if (call.callState == CTCallStateIncoming)
    {
        NSLog(@"Call is incoming");

    }
    else if (call.callState == CTCallStateDialing)
    {
        NSLog(@"Call is Dialing");
    }
    else
    {
        NSLog(@"None of the conditions");
    }
}
 }

Thanks in advance.

Upvotes: 0

Views: 1268

Answers (1)

manujmv
manujmv

Reputation: 6445

You have to include Core Telephony Framework and import it in CallEventAppDelegate

#import <CoreTelephony/CTCall.h>
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>

Upvotes: 1

Related Questions