This video is a recording of an app which can
- over-ride silent mode
- over-ride locked screen
- play alarm music/melody
Our team is working on a similar custom iphone alarm clock
I would be so grateful if someone could help. I have been trying to break this for two weeks.
our below method is not called when device is locked. that's why alarm sound is not playing
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
if ([GlobalData gSettings].vibration) {
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
isVibration = YES;
} else {
isVibration = NO;
}
self.uinfo = notification.userInfo;
NSString *soundname = [uinfo objectForKey:@"sound"];
NSURL *clip = [[NSBundle mainBundle] URLForResource:soundname withExtension:@"caf"];
if (clip) {
self.avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:clip error:NULL];
self.avPlayer.delegate = self;
AudioSessionInitialize (NULL, NULL, NULL, NULL);
AudioSessionSetActive(true);
// Allow playback even if Ring/Silent switch is on mute
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
sizeof(sessionCategory),&sessionCategory);
}
else
{
NSURL *clip = [[NSUserDefaults standardUserDefaults]URLForKey:[uinfo objectForKey:@"sound"]];
self.avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:clip error:NULL];
self.avPlayer.delegate = self;
AudioSessionInitialize (NULL, NULL, NULL, NULL);
AudioSessionSetActive(true);
// Allow playback even if Ring/Silent switch is on mute
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
sizeof(sessionCategory),&sessionCategory);
}
[self.avPlayer play];