I would write as much as I could write here, but the Title pretty much says it all. I've tested it in several different situations:
1) Phone on, silent mode off, app on, in foreground, screen unlocked
I know that this goes through app delegate's didReceiveLocalNotification and didn't expect a sound or vibration, except for the handling code that I included under didReceiveLocalNotification. The handling code actually called
NSURL *Sound = [[NSBundle mainBundle] URLForResource: self.currentSoundPVC
withExtension: @"caf"];
// Create a system sound object representing the sound file.
AudioServicesCreateSystemSoundID (soundFileURLRef,&soundFileObject);
AudioServicesPlayAlertSound (soundFileObject);
and that actually works! It plays a sound and vibrates the phone simultaneously.
2) phone on, silent mode off, app on, in background, screen unlocked
Now, I set up my uilocalnotification alarms in app delegate's applicationDidEnterBackground, using the following code
NSString *Sound = [self.currentSoundPVC stringByAppendingString:@".caf"];
UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];
alarm.fireDate = [NSDate dateWithTimeIntervalSinceNow:seconds];
[alarm setSoundName:Sound];
[[UIApplication sharedApplication] scheduleLocalNotification:alarm];
and this only partially works! The sound gets played but there is NO VIBRATION! Now, this I think is a bug because I am quoting from the apple developer website,
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html, Scheduling the Delivery of Local Notifications section:
"When the notification is sent and the sound is played, the system also triggers a vibration on devices that support it. "
Now, obviously that is NOT THE CASE for my iPhone and obviously the simulator doesn't vibrate, so I can't test this and would like to have this addressed in the developer community!
3) phone on, silent mode off, app on, in foreground, screen locked
Same as #2
4) phone on, silent mode off, app on, in background, screen locked
Same as #2
5) phone on, silent mode off, app off (background process deleted)
Same as #2, because the uilocalnotifications were never cancelled, so the iOS still thinks they are valid.
6) phone on, silent mode on, app on, in background, screen unlocked
no sound, no vibration, NOTHING! This sucks! I would have hoped that apple would have come up with something that works straight out of the box, as usual!