Ios 通过移动网络上传数据-目标C

Ios 通过移动网络上传数据-目标C,ios,iphone,objective-c,phone-call,Ios,Iphone,Objective C,Phone Call,在我的应用程序中,当用户接到一些电话时,我试图上传一些数据。那么,在接到电话或正在通话时,是否可以通过GSM数据网络上传数据?谢谢。您可以使用核心电话框架中的CTCallCenter类注册事件处理程序,以便在呼叫开始或结束时通知您的应用程序,在那里您可以做任何您想做的事情 CTCall提供以下callState属性 ctcallstatedilling CTCallStateIncoming CTCallStateConnected CTCallStateDisconnected 希望它能帮助您

在我的应用程序中,当用户接到一些电话时,我试图上传一些数据。那么,在接到电话或正在通话时,是否可以通过GSM数据网络上传数据?谢谢。

您可以使用
核心电话框架
中的
CTCallCenter
类注册事件处理程序,以便在呼叫开始或结束时通知您的应用程序,在那里您可以做任何您想做的事情

CTCall提供以下callState属性

ctcallstatedilling

CTCallStateIncoming

CTCallStateConnected

CTCallStateDisconnected


希望它能帮助您解决问题。

首先,您需要在项目中添加CoreTephony框架

请尝试以下代码。它将使您清楚地了解流程

#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;
}
#导入
#进口
静态CTCallCenter*呼叫中心;
@实现AppDelegate
-(无效)解除锁定
{
[窗口释放];
[_viewcontrollerrelease];
[super dealoc];
}
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项
{
self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]边界]]自动释放];
//应用程序启动后自定义的覆盖点。
self.viewController=[[viewController alloc]initWithNibName:@“viewController”bundle:nil]autorelease];
self.window.rootViewController=self.viewController;
[self.window makeKeyAndVisible];
如果([[UIDevice currentDevice].systemVersion floatValue]>=4.0)
{
callCenter=[[CTCallCenter alloc]init];
callCenter.callEventHandler=^(CTCall*call)
{
NSLog(@::调用id:%@),Call.callID;
if(call.callState==ctcallstatedilling)
{
NSLog(@)::呼叫状态:拨号“;
}
if(call.callState==ctcallstateinoming)
{
NSLog(@)::呼叫状态:传入“;
}
if(call.callState==CTCallStateConnected)
{
NSLog(@)::呼叫状态:已连接“;
}
if(call.callState==CTCallStateDisconnected)
{
NSLog(@)::呼叫状态:已断开”);
}
};
}
返回YES;
}

您是否正在尝试录制通话并向您发送数据?根据我的信息,如果你有3G或更高版本的互联网,我们可以使用互联网