在iOS中拨打电话时调用标头的方法是什么? [英] Which method from which header is called when making a phone call in iOS?

查看:191
本文介绍了在iOS中拨打电话时调用标头的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过ios open dev中的徽标模板进行调整,但我一直在查看现有框架中的所有头文件,而我找不到正确的标题,其中有一个方法在有人拨打电话后调用?有谁知道它是哪个?
我正在尝试做一些类似AskToCall的东西,它可以在Cydia中提供,在拨打电话时提示UIAlertView,正好是按下绿色按钮时。

I'm developing a tweak through logos template from ios open dev, but I've been looking around all header files in existing frameworks and I'm not finding the correct header which have method that's called after someone make a phone call ? Does any one know which it is ? I'm trying to do something like "AskToCall" which is available in Cydia that prompts an UIAlertView when a phone call is made, exactly when green button is pressed.

谢谢!

推荐答案

1)首先,您需要链接私有框架CoreTelephony:在您的徽标项目的Makefile中确保你包括yourprojectname_PRIVATE_FRAMEWORKS = CoreTelephony。还要确保你的MobileSubstrate .plist文件过滤com.apple.mobilephone

1) First you need to link against private framework CoreTelephony: in your logos project's Makefile make sure you include yourprojectname_PRIVATE_FRAMEWORKS = CoreTelephony. Also make sure your MobileSubstrate .plist file filters "com.apple.mobilephone"

2)iPhone上的手机应用程序使用CoreTelephony的CTCallDialWithID函数进行调用。您可以简单地挂钩函数并改为执行。

2) The phone application on iPhone uses CoreTelephony's CTCallDialWithID function to make calls. You can simply hook the function and do your thing instead.

#import "substrate.h" // for MSHookFunction definition

extern "C" void CTCallDialWithID(NSString *numberToDial); // function declaration

static void (*original_CTCallDialWithID)(NSString *numberToDial); //define a function pointer on which you'll assign the original call later

static void replaced_CTCallDialWithID(NSString *numberToDial){
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Verify New Call" message:[NSString stringWithFormat:@"Are you sure you want to call %@",numberToDial]
                         delegate:YOUR_OBJECT cancelButtonTitle:@"No" otherButtonTitles:@"Yes,please",nil];
    [alert show];
    [alert release];
}

在你的构造函数中:

%ctor{
      %init();
      MSHookFunction((void *)CTCallDialWithID,(void *)replaced_CTCallDialWithID,(void **)&original_CTCallDialWithID);
      // Replace original function implementation with your replaced_ one.

}

最终实际拨打该号码(例如在您的alertview代表中) 。)在你替换了函数实现之后,使用

To actually dial the number eventually (e.g. in your alertview's delegate.) after you've replaced the function implementation, use

CTCallDial(NSString *number);

因为CTCallDialWithID需要{...}参数并且无法正常运行。

because CTCallDialWithID expects {...} parameters and will not function correctly.

请注意,这是一个用于CTCallDialWithID的Phone.app中的全局钩子(我适用于所有拨出的电话,包括点击最近拨打电话或收藏的电话等

如果您只是在按下呼叫按钮时需要一个挂钩:

If you simply need a hook for just when pressing the Call button:

%hook DialerController
-(void)_callButtonPressed:(id)pressed{

   UIView *dialerView=MSHookIvar<UIView *>(self,"_dialerView");
   UILabel *lcd=MSHookIvar<UILabel *>(dialerView,"_lcd");
   NSString *numberToBeDialed=[lcd text];

  // do your thing with the number in here.
}
%end

我注意到你提到你发现了这个方法较早,但没有用。它可能不适合你,因为你没有注入MobilePhone.app。

I noticed you mentioned you found this method earlier and didn't work. It probably didn't work for you because you're not injecting in MobilePhone.app.

你的theos项目中的.plist文件如下所示:

Your .plist file in your theos project should look like:

Filter = { Bundles = ("com.apple.mobilephone");};

这篇关于在iOS中拨打电话时调用标头的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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