ios - 本地通知问题

标签 ios objective-c uilocalnotification

我正在尝试在数组日期与当前日期相同时收到通知,这段代码是我用于此任务的

NSDateFormatter *Form = [[NSDateFormatter alloc] init];
    [Form setDateFormat:@"dd/MM/yyyy"];

    UILocalNotification *notification = [[UILocalNotification alloc] init];
    for (int i=0;i<_convertedBdates.count;i++)
    {
        NSDate *date =[Form dateFromString:[_convertedBdates objectAtIndex:i ]];
        NSLog(@"date%@",date);

    if(notification)
        {
            notification.fireDate = date;
            notification.timeZone = [NSTimeZone defaultTimeZone];
            notification.alertBody = @"New ";
            notification.alertAction = @"View";

            notification.soundName = UILocalNotificationDefaultSoundName;
            notification.applicationIconBadgeNumber = 1;
            [[UIApplication sharedApplication] scheduleLocalNotification:notification];
        }
    }

建议我做错了什么

最佳答案

您是否已将此代码放入您的应用委托(delegate)中?

 - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
    NSLog(@"Notification Received, %@, set for date %@", notification.alertBody, notification.fireDate);
}

如果问题仍然存在,那么我在这里 :)

关于ios - 本地通知问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15516332/

相关文章:

ios - 扫描网络设备

ios - 未完成的执行警告

ios - 应用程序运行时如何在后台进行服务调用 ios

objective-c - 在自定义 View 中重现 tableView 委托(delegate)行为

ios - 是否可以在 iOS 中安排 SILENT 本地通知?

ios - C4 保存图像的一部分

ios - 我有一个 Storyboard,我插入这个。我想在启动 Controller 之前在 Storyboard上获取控件的名称。如何?

iphone - 通配符应用程序ID和捆绑ID的命名

ios - UILocalNotification 和 applicationIconBadgeNumber 的良好模式

ios - 使用 Swift 每周重复本地通知