Ios iphone中使用核心电话的呼叫事件
我正在尝试在我的iPhone应用程序中获取呼叫事件。 为此,我试图注册到核心电话通知,但我得到以下错误。我正在iPhone3GS上测试这个Ios iphone中使用核心电话的呼叫事件,ios,iphone,objective-c,core-telephony,Ios,Iphone,Objective C,Core Telephony,我正在尝试在我的iPhone应用程序中获取呼叫事件。 为此,我试图注册到核心电话通知,但我得到以下错误。我正在iPhone3GS上测试这个 Undefined symbols for architecture armv7: "CTTelephonyCenterGetDefault()", referenced from: -[CallEventAppDelegate application:didFinishLaunchingWithOptions:] in CallEventAppDe
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");
}
}
}
提前感谢。您必须包括核心电话框架,并将其导入CalleenTappDelegate中
#导入
#进口
#进口
#进口
我已经包括了所有这些核心电话框架。Wehn我的appdelagate有扩展名.mm,那个时候我得到了上面的错误。当我将其改为.m时,应用程序正在启动,但它崩溃了,我在后续工作中遇到了严重问题。telephonyEventCallback,//callback我更改了代码及其工作方式。现在我在前台收到来电事件,但无法在前台收到来电断开事件。当应用程序处于后台时,我不会收到任何事件。请在这方面帮助/指导我。谢谢
#import <CoreTelephony/CTCall.h>
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>