拦截电话 - iPhone(在CoreTelephony中挂钩的正确方法) [英] Intercepting phone call - iPhone (correct method to hook in CoreTelephony)

查看:122
本文介绍了拦截电话 - iPhone(在CoreTelephony中挂钩的正确方法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是越狱调整开发场景的新手。我试图弄清楚'钩'的适当方法,这样我就可以拦截来电(然后运行一些代码)。

I am new to the jailbreak tweak development scene. I am trying to figure out the appropriate method to 'hook' so I can intercept an incoming call (and then run some code).

我已经转储了头文件然而,CoreTelephony框架没有任何方法似乎很明显。我试过了:

I have dumped the header files of CoreTelephony framework however no methods seem obvious to hook. I have tried:

- (void)broadcastCallStateChangesIfNeededWithFailureLogMessage:(id)arg1;
- (BOOL)setUpServerConnection;

但两项都没有奏效。通过工作我的意思是 - 当iPhone接到电话时被叫。

but neither have worked. By worked I mean - get called when the iPhone receives a call.

有关挂钩的适当方法的任何指示?谢谢:)

Any pointers as to the appropriate method to hook? Thanks :)

注意:
这将是一个使用私有API的越狱调整,因此它不会被提交到App Store。

推荐答案

我没有测试你的代码,但我认为你的问题可能是你需要使用核心电话通知中心注册该事件(不是您在评论中的代码中所拥有的)。这样的事情:

I didn't test your code, but I think your problem might be that you need to use the Core Telephony notification center to register for that event (not what you had in the code in your comment). Something like this:

// register for all Core Telephony notifications
id ct = CTTelephonyCenterGetDefault();
CTTelephonyCenterAddObserver(ct,   // center
                             NULL, // observer
                             telephonyEventCallback,  // callback
                             NULL,                    // event name (or all)
                             NULL,                    // object
                             CFNotificationSuspensionBehaviorDeliverImmediately);

您的回调函数是

static void telephonyEventCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
    NSString *notifyname = (NSString*)name;
    if ([notifyname isEqualToString:@"kCTCallIdentificationChangeNotification"])
    {
        NSDictionary* info = (NSDictionary*)userInfo;
        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");
        }
    }
}

我提供另一种技术这里的类似问题。另外,请注意我在该问题中的评论,该问题是关于未在 UIApplication 中获取通知已被置于后台。

I offer another technique in this similar question here. Also, note my comment in that question about not getting the notifications in a UIApplication that has been put into the background.

更新:请参阅下面关于在iOS 6上使用 kCTCallStatus 而不是 kCTCall 的cud_programmer的评论。

Update: see cud_programmer's comment below about using kCTCallStatus on iOS 6 instead of kCTCall.

这篇关于拦截电话 - iPhone(在CoreTelephony中挂钩的正确方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆