如何为 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
但振动不在你的控制范围内:
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
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
关于objective-c - 向 LocalNotifications 发出振动和声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14084175/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |