0

我正在尝试在我的 iPhone 应用程序中获取通话事件。为此,我正在尝试注册 Core Telephony 通知,但出现以下错误。我正在 iPhone 3GS 上进行测试。

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

这是我的示例代码:-

    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");
    }
}
 }

提前致谢。

4

1 回答 1

1

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>
于 2013-11-14T06:47:05.427 回答