如何设置每日每周和每年的本地通知

时间:2011-08-22 09:52:52

标签: iphone objective-c ios localnotification

我有一个iPhone应用程序,我每天用它来解雇UILocalnotification,每周和每年有没有任何好的教程,使用此代码来设置通知

- (void)alertSelector:(NSString *)AlertTitle WithFiringTime:(NSDate *)date{
    UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease];

    if (!localNotification) 
        return;
    // Set the fire date/time
    [localNotification setFireDate:date];
    [localNotification setTimeZone:[NSTimeZone defaultTimeZone]];

    // Create a payload to go along with the notification   
    NSDictionary *data = [NSDictionary dictionaryWithObject:date forKey:@"payload"];
    [localNotification setUserInfo:data];

    // Setup alert notification
    [localNotification setAlertBody:AlertTitle];
    [localNotification setAlertAction:@"View"];
    [localNotification setHasAction:YES];      

    [UILocalNotification setBadge];

//   localNotification.soundName = UILocalNotificationDefaultSoundName;
//   localNotification.soundName=@"voice.aif";

    // Schedule the notification        
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

thankx

1 个答案:

答案 0 :(得分:1)

也许this tutorial有帮助...