对于尚未创建的通知(新通知)已更改,但对于已创建的通知,将保留先前的声音。

我努力了:

NSString *soundName = cell.titleLabel.text;

NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications];

for (UILocalNotification *notif in notifications) {
    notif.soundName = [NSString stringWithFormat:@"%@.mp3", soundName];
}

但这行不通...

最佳答案

您必须重新安排已安排的通知。但是,请确保删除以前安排的内容。

NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

for (UILocalNotification *notif in notifications) {
    notif.soundName = [NSString stringWithFormat:@"%@.mp3", soundName];
    [[UIApplication sharedApplication] scheduleLocalNotification:notification];
}

关于iphone - 更改已设置的UILocalNotification的soundName,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14674540/

10-13 05:42