I'm working on a personal tweak for iOS. I want to disconnect/connect a phone call before the phone would show anything. I'm hooking into the initWithAlertController:
method of class SBUIFullscreenAlertAdapter
. Everything is okay when I just show a message that shows the incoming phone number and its name, but when i try to answer the phone call or disconnect it programmatically, it will crash and go to safe mode.
Here is my code:
@interface SBUIFullscreenAlertAdapter
- (id)initWithAlertController:(id)arg1;
@end
@interface MPIncomingPhoneCallController
{
struct __CTCall *_incomingCall;
}
- (id) incomingCallNumber;
- (void)stopRingingOrVibrating;
- (void)answerCall:(struct __CTCall *)arg1;
@end
%hook SBUIFullscreenAlertAdapter
- (id)initWithAlertController:(id)arg1
{
MPIncomingPhoneCallController *phoneCall = (MPIncomingPhoneCallController*)arg1;
[phoneCall stopRingingOrVibrating];
if([phoneCall.incomingCallNumber isEqualToString:@"+98.........."]) {
[phoneCall answerCall:_incomingCall];
}
%orig;
return self;
}
%end
The error is that it says: "Use of undeclared identifier '_incomingCall'".
How can I solve the problem? Is there a way to use a private instance variable while hooking a method? Is there a function which returns a CTCallRef*
of the incoming call? Is there some other way to accomplish this?
It should be obvious that I'm coding for jailbroken iOS devices, so there is no problem with the use of private frameworks.