OGeek|极客世界-中国程序员成长平台

标题: ios - 本地通知问题 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 09:47
标题: ios - 本地通知问题

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

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];
        }
    }

建议我做错了什么



Best Answer-推荐答案


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

 - (void)applicationUIApplication *)application didReceiveLocalNotificationUILocalNotification *)notification
{
    NSLog(@"Notification Received, %@, set for date %@", notification.alertBody, notification.fireDate);
}

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

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






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4