震动和声音LocalNotifications

如何为LocalNotifaction添加振动和声音

码:

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

你可以设置声音:

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

但振动不在您的控制范围之内:

不幸的是,如果你想要一个声音,你不能禁用振动,除非用户进入常规设置并禁用振动。 -shabzco

UILocalNotification API可让您设置系统默认声音,select声音或没有声音,如果您有一些声音,则会在正确的环境下(即用户启用振动)振动。 但除此之外,你无法控制振动是否发生或持续多久。 -yuji