2012-12-29 89 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