我想在到达“时间”时通知用户。
例如:
我有一个包含很多行的表格 View 。这些行类似于提醒,用户可以在其中设置提醒的日期和时间。
于是连续把提醒设置为4月24日12:15。
此时App关闭。
那么我该如何通知用户这个时间到了呢?
有没有没有苹果推送通知服务的方法?
编辑 1:
感谢您的回答,以下是本地通知的示例:
//This example adds 20 seconds to current time, use it for testing
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
NSDate *currentDate = [NSDate date];
NSDate *currentDatePlus = [currentDate dateByAddingTimeInterval:20];
localNotification.fireDate = currentDatePlus;
localNotification.alertBody = @"Hallo ayFon User";
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
编辑 2:
//Add this for iOS 5 Notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
最佳答案
您必须使用 iOS 的本地通知。他们正是为了这个目的而完成的。
您可以在此处找到文档:Local and Push Notification Programming Guide .
关于iphone - 如何在 ios 中通知用户,而应用程序关闭/在后台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10294961/