振动和声音到 LocalNotifications [英] Vibrate and sound to LocalNotifications
问题描述
我如何向 LocalNotifaction 添加振动和声音
How I add vibrate and sound to 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
但振动不在您的控制范围内:
But vibration is outside your control:
不幸的是,如果您想要声音,则无法禁用振动,除非用户已进入常规设置"并自行禁用振动.-shabzco
Unfortunately, if you want a sound, you can't disable vibration unless the user has went into the General Settings and disabled vibration themselves. -shabzco
UILocalNotification API 允许您设置系统默认声音、选择声音或没有声音,如果您有声音,它会在适当的情况下振动(即用户启用了振动).但除此之外,您无法控制是否发生振动或持续多长时间.-yuji
The UILocalNotification API lets you set the system default sound, choose a sound, or have no sound, and if you have some sound, it will vibrate under the right circumstances (i.e., the user has enabled vibration). But beyond that, you have no control over whether vibration occurs or how long it lasts. -yuji
这篇关于振动和声音到 LocalNotifications的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!