How to hook to a function to iOS alarms?

376 views Asked by At

I'm trying to use Theos in order to hook up and capture the names of the alarms that have been stopped.

I have done this:

// Logos by Dustin Howett
// See http://iphonedevwiki.net/index.php/Logos
//#import <SpringBoard/SpringBoard.h>
#import <MobileTimer/AlarmManager.h>
//#import <SpringBoard/SBApplicationIcon.h>
#import <UIKit/UIKit.h>
//#import <SpringBoard/SBRemoteNotificationEnableSystemwideAlert.h>

%hook AlarmManager

- (void)handleAlarm:(id)arg1 stoppedUsingSong:(id)arg2 {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"ALARM!!!!" message:@"HELLO!!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    %orig(arg1,arg2);
}
%end

The problem is that I never see the alertbox. Do you have any ideas why this is?

1

There are 1 answers

3
Robin Vekety On

After [alert show]; put [alert release]; This:

%hook AlarmManager 
    - (void)handleAlarm:(id)arg1 stoppedUsingSong:(id)arg2 {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"ALARM!!!!" message:@"HELLO!!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    %orig(arg1,arg2);
}
%end