Starting app on text message receive using theos tweak

1.8k Views Asked by At

I'm trying to start an app if I receive an text message from an special sender. Currently my Tweak.xm looks like this:

#import <SpringBoard/SpringBoard.h>
#import <UIKit/UIKit.h>
#import <ChatKit/ChatKit.h>
#import <ChatKit/CKSMSMessage.h>
#import <ChatKit/CKSMSEntity.h>
#import <ChatKit/CKSMSService.h>
#import <ChatKit/CKConversation.h>

#import <CoreTelephony/CoreTelephony.h>

%hook SMSCTServer
- (void)_ingestIncomingCTMessage:(CTMessage *)arg1
{
  %orig;
  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome"
        message:@"Received :D!"
        delegate:nil
        cancelButtonTitle:@";)"
        otherButtonTitles:nil];
    [alert show];
    [alert release];
}
%end
%hook SpringBoard

-(void)applicationDidFinishLaunching:(id)application {
    %orig;

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome"
        message:@"Test!"
        delegate:nil
        cancelButtonTitle:@"Test"
        otherButtonTitles:nil];
    [alert show];
    [alert release];
}

%end

%hook CKSMSService

-(void)_receivedMessage:(CKSMSRecordRef)message replace:(BOOL)replace{

    NSLog(@"received message  %@", message);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome"
        message:@"Welcome to your iPhone Brandon!"
        delegate:nil
        cancelButtonTitle:@"Thanks"
        otherButtonTitles:nil];
    [alert show];
    [alert release];

        %orig;
}

%end

and this is the makefile:

include theos/makefiles/common.mk

TWEAK_NAME = Mytweak
Mytweak_FILES = Tweak.xm
Mytweak_FRAMEWORKS = ChatKit Foundation CoreGraphics UIKit AudioToolbox
Mytweak_PRIVATE_FRAMEWORKS = CoreTelephony
include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
        install.exec "killall -9 SpringBoard"

But I don´t know how to install the Coretelephonyframework, I always get the error:

Tweak.xm:8:9: fatal error: 'CoreTelephony/CoreTelephony.h' file not found
import <CoreTelephony/CoreTelephony.h>

Does anyone know how to install the framework into theos? I am completely new to jailbreakapp coding.

2

There are 2 best solutions below

0
Connor Pearson On

This answer shows how to use class dump to get the private headers for CoreTelephony. Once you have the headers put them in the include directory for theos. I think /var/theos/include is the default. I hope this helps.

0
user3025315 On

CoreTelephony.h is unnecessary for your tweak