gpt4 book ai didi

iphone - 更改已设置的 UILocalNotification 的 soundName

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:45:19 25 4
gpt4 key购买 nike

对于尚未创建的通知(新通知)它会更改,但对于已经创建的通知,之前的声音会保留。

我试过:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com