且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iphone sdk到达时的本地通知

更新时间:2023-02-26 21:05:19

您可以在iOS 4中使用

You can send local notifications in iOS 4, using UILocalNotification class.

以下是一些示例代码:

UILocalNotification *noti = [[UILocalNotification alloc] init];
noti.fireDate = someDate;
noti.alertBody = someText;
noti.alertAction = nil;
noti.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:noti];
[noti release];

不过,我不知道它是否可以在后台模式下工作.确保该日期与[NSDate日期]尽可能接近,因此它将立即显示.

I don't know if it will work in background mode, though. Make sure the date is as close as posible as [NSDate date], so it will appear right away.