I am trying to put a UIButton into iPhones MobileSMS.app (messages app). It sucessfully appears in the view, but when you press it, it crashes of course because it is not calling any target class and hooking a method. The target class and method I would like to hook is in the second code below, how can I achieve calling this when the button is pressed? (my main goal is to put a button in the conversation view and when it is tapped it will force SMS instead of automatically using iMessage.)
#import <UIKit/UIKit.h>
#import <ChatKit/ChatKit.h>
@interface CKTranscriptCollectionViewController : UIViewController
@end
%hook CKTranscriptCollectionViewController
-(void)loadView {
%orig;
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"SMS" forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, 50, 100);
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
-(void)buttonPressed {
NSLog(@"Button Pressed!");
}
%end
Class and method I would like to call when button is tapped(which belongs in the header "ChatKit/CKConversation.h"):
%hook CKConversation
-(BOOL)forceMMS {
return TRUE;
}
%end