0

我有一个 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];
}

谢谢

4

1 回答 1

1

也许本教程可以帮助...

于 2011-08-22T11:38:39.843 回答