Disconnect or connect an iPhone call programmatically

前端 未结 2 1770
礼貌的吻别
礼貌的吻别 2021-01-03 09:50

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

2条回答
  •  抹茶落季
    2021-01-03 10:36

    For iOS 8.*:

    The hooking seems pretty easy with Theos/Logos.

    Example Tweak.xm file (you need the TelephonyUtilities private framework headers for 8.1):

    #import "TelephonyUtilities/TUTelephonyCall.h"
    
    %hook MPTelephonyManager
    
    -(void)displayAlertForCall:(TUTelephonyCall*)phoneCall { // for iOS 9: displayAlertForCallIfNecessary
        NSLog(@"hooked displayAlertForCall method");
        if ([[NSBundle mainBundle].bundleIdentifier isEqualToString:@"com.apple.springboard"]) { // (don't know if required)
            [phoneCall answer]; // or [phoneCall disconnect];
        }
        %orig;
    }
    
    %end
    
    
    %ctor {
        if ([[NSBundle bundleWithPath:@"/System/Library/SpringBoardPlugins/IncomingCall.servicebundle"] load]) {
            NSLog(@"IncomingCall.servicebundle loaded succesfully!");
        }
        else {
            NSLog(@"IncomingCall.servicebundle did not load succesfully.");
        }
    }
    

    Credit to Phillip Tennen (https://github.com/codyd51/CallConnect)

提交回复
热议问题