2

对于尚未创建的通知(新通知)进行了更改,但对于已创建的通知,之前的声音保持不变。

我努力了:

NSString *soundName = cell.titleLabel.text;

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

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

但它不起作用......

4

1 回答 1

1

您必须重新安排已安排的通知。但请确保删除您之前安排的那些。

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

for (UILocalNotification *notif in notifications) {
    notif.soundName = [NSString stringWithFormat:@"%@.mp3", soundName]; 
    [[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
于 2013-10-09T10:30:46.197 回答