如何在 iphone sdk objective c 中编辑本地通知

how to edit local notifications in iphone sdk objective c

我正在 xcode 6 中开发一个虚拟项目并创建本地通知。我已经创建并删除了这些本地 notifications.Now 我想编辑一个特定的通知。

您不能更改已安排的通知。
您必须取消,然后使用您需要的新数据重新创建它。

您可以询问当前排期UILocalNotifications:

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

循环数组并检查它是否是您需要更改的通知:

for (UILocalNotification *notification in scheduledNotifications)
{
    //Get the ID you set when creating the notification
    NSDictionary *userInfo = notification.userInfo;
    NSNumber *someValueYouGaveWhenCreatingCouldBeAnIdentifierOfAnObject = [userInfo objectForKey:@"someKey"];

    if (someValueYouGaveWhenCreatingCouldBeAnIdentifierOfAnObject == someCheckYouHaveToDoHere)
    {
        [[UIApplication sharedApplication] cancelLocalNotification:notification];
        //Re-create the localnotification with new data and the someValueYouGaveWhenCreatingCouldBeAnIdentifierOfAnObject

        break;
    }
}