我正在尝试在我的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");
}
}
}
提前致谢。
最佳答案
您必须包括Core Telephony Framework并将其导入CallEventAppDelegate中
#import <CoreTelephony/CTCall.h>
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
关于ios - 使用Core Telephony的iPhone中的通话事件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19970304/