I have recently been trying to get into iOS development using Theos and Obj-C. I currently am attempting to write a tweak for an iPhone 5s running 8.1.1 that is jailbroken. I am currently compiling everything on the device over SSH. I have been attempting to write a tweak that simply displays an alert whenever the Springboard is loaded(so right after the device first resprings). Despite searching around I havent been able to find an solution. When I install the .deb and respring, I see no alert. I am very confused as to why it is not showing, here is the code I have in my tweak.xm file.
%hook SpringBoard // Hook SpringBoard, because that is the class that has the method you want to hook
-(void)applicationDidFinishLaunching // When this method is called, you want to execute your code
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"AlertView in iOS 8" message:nil preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self dismissViewControllerAnimated:YES completion:nil];
}]];
[self presentViewController:alertController animated:YES completion:nil];
%orig; // call normal function so SpringBoard loads.
}
%end
I had an incredibly difficult time getting that code there so here's a mode readable version https://ghostbin.com/paste/fmv6m
I can post my control and makefile as well if needed.
To summarize: The package is created with that code but it doesn't do anything. I would like to know why and how I would fix it so that an alert will display when Springboard is loaded.
Thank you for reading
Use the lockscreen's view controller. Hook SBLockScreenViewController
's viewDidAppear