【问题标题】:Change soundName of already set UILocalNotification更改已设置 UILocalNotification 的 soundName
【发布时间】:2013-02-03 16:18:29
【问题描述】:
对于尚未创建的通知(新通知)进行更改,但对于已创建的通知,将保留之前的声音。
我试过了:
NSString *soundName = cell.titleLabel.text;
NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications];
for (UILocalNotification *notif in notifications) {
notif.soundName = [NSString stringWithFormat:@"%@.mp3", soundName];
}
但它不起作用......
【问题讨论】:
标签:
iphone
ios
ipad
alert
uilocalnotification
【解决方案1】:
您必须重新安排已安排的通知。但请确保删除您之前安排的那些。
NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
for (UILocalNotification *notif in notifications) {
notif.soundName = [NSString stringWithFormat:@"%@.mp3", soundName];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}