I am using UILocalNotification
to alert the user if app not running and MPMusicPlayerController
to play iPod music and MPMoviePlayerController
use AVAudioSessionCategoryPlayback
for audio session. Check audio session programming guide here
@manju sorry i got late but it work for you.
selectedDate = [timePicker date];
it is selectedDate date object,at this time your notification will came.
[NSDate date]
by this you can find current time. and find different both time via.
NSTimeInterval timeDifference = [ selectedDate timeIntervalSinceDate:[NSDate date]];
Now when your are schedule your notification then .write this code
UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier bgTask = 0;
NSTimer *backgroundTimer = [NSTimer scheduledTimerWithTimeInterval:timeDifference target:self selector:@selector(backgroundTask) userInfo:nil repeats:NO];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
}];
-(void)backgroundTask
{
NSLog(@"Here you can play song via player ");
}
Don't forgot to add in app.infolist
UIApplication BackgroundMode Audio it will solve your problem , play song when device is lock.