iphone - 如何在 ios 中通知用户,而应用程序关闭/在后台

标签 iphone ios notifications push-notification reminders

我想在到达“时间”时通知用户。

例如:

我有一个包含很多行的表格 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/

相关文章:

iphone - 如何获取 NSURLConnection 中的默认用户代理字符串?

iphone - 在选项卡栏应用程序中弹出到根 ViewController

iphone - 在 Storyboard中,如何在不单击按钮的情况下插入segue

iOS Swift - 如何响应横幅通知?

ios - swift - Twilio 视频聊天 - 卡住时发出警报

Android 4.x 设备接收 GCM 消息,但 Android 2.3 设备不接收

android - 具体时间通知

iphone - 通过分段控件在标准样式表和分组样式表之间翻转

ios - UITableView 在 iPad 上没有填满整个屏幕

ios - 我可以收到其他应用程序通知的提醒吗