停用和激活特定的 UILocalNotification

deactivate and activate a specific UILocalNotification

我必须做什么才能取消特定的 UILocalNotification?

我相信您正在寻找取消特定本地通知的方法。如果这正是您要找的,这可能对您有所帮助。

下面是取消本地通知的代码。

[[UIApplication sharedApplication] cancelLocalNotification:localNotification]

如果您的通知不是全局的,则用于识别特定的 UILocalNotification。

for (UILocalNotification *localNotification in [[UIApplication sharedApplication] scheduledLocalNotifications])
{
    NSDictionary* userInfo = localNotification.userInfo;
    if ([[userInfo objectForKey:@"name"] isEqualToString:@"NAME_OF_NOTIFICATION"]) {
        [[UIApplication sharedApplication] cancelLocalNotification:localNotification];
        break;
    }
}

这里,我使用了UILocalNotifications userinfo来识别具体的UILocalNotification。您可以使用 alertTitle 等其他东西来识别不同的 UILocalNotifications

希望对您有所帮助:)