2012-12-29 85 views
2

我怎么加振动和声音LocalNotifaction振动和声音LocalNotifications

代码:

UILocalNotification *notification = [[UILocalNotification alloc]init]; 

NSDate *firedate = settime.date; 
[notification setFireDate:firedate]; 
[notification setAlertBody:@"הלכה יומית"]; 
[notification setAlertAction:@"הלכה"]; 



[[UIApplication sharedApplication]scheduleLocalNotification:notification]; 

回答

4

您可以设置声音:

notification.soundName = @"yourSound.aiff" ; // see also UILocalNotificationDefaultSoundName 

但振动是你的控制范围之外:

不幸的是,如果您想要声音,除非用户进入常规设置并禁用振动,否则无法禁用振动。 -shabzco

的UILocalNotification API允许您设置系统默认的声音,选择一种声音,或者有没有声音,如果你有一些声音,它会在合适的环境振动(即,用户已启用振动)。但除此之外,你无法控制振动是否发生或持续多久。 -yuji