通过移动网络上传数据 - 目标C
答
您可以使用Core Telephony framework
中的CTCallCenter
类来注册事件处理程序,以便在通话开始或结束时通知您的应用程序,并且您可以在其中执行任何操作。
的CTCall提供了以下callState财产
CTCallStateDialing
CTCallStateIncoming
CTCallStateConnected
CTCallStateDisconnected
希望它可以帮助你解决你的问题。
答
首先,您需要在您的项目中添加CoreTelephony框架。
请尝试下面的代码。它会让你清楚地理解流程。
#import <CoreTelephony/CTCall.h>
#import <CoreTelephony/CTCallCenter.h>
static CTCallCenter *callCenter;
@implementation AppDelegate
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
if([[UIDevice currentDevice].systemVersion floatValue] >= 4.0)
{
callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler=^(CTCall* call)
{
NSLog(@":: Call id:%@",call.callID);
if (call.callState==CTCallStateDialing)
{
NSLog(@":: Call state:dialing");
}
if (call.callState==CTCallStateIncoming)
{
NSLog(@":: Call state:incoming");
}
if (call.callState==CTCallStateConnected)
{
NSLog(@":: Call state:Connected");
}
if (call.callState==CTCallStateDisconnected)
{
NSLog(@":: Call state:Disconnected");
}
};
}
return YES;
}
您是否试图记录呼叫并将数据发送给您?根据我的信息,如果您有3G或更高版本的互联网,我们可以使用互联网 –