Ios 如何在目标C中进行注册通知?

Ios 如何在目标C中进行注册通知?,ios,objective-c,apple-push-notifications,ios9.1,Ios,Objective C,Apple Push Notifications,Ios9.1,我有一台在线收音机。收音机在不同的时间播放节目,节目显示在列表中。 我需要的是,当点击并按住程序列表时,他会向用户发送通知 列表中的示例程序: 点击并保持已在运行(代码如下): 该测试的通知时间为“09:00”(直接 格式(JSON) appDelegate.m我添加: -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

我有一台在线收音机。收音机在不同的时间播放节目,节目显示在列表中。 我需要的是,当点击并按住程序列表时,他会向用户发送通知

列表中的示例程序:

点击并保持已在运行(代码如下):

该测试的通知时间为“09:00”(直接 格式(JSON)

appDelegate.m我添加:

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

}

看了几本教程,在不同的地方进行了研究,我无法以任何方式解决我的问题。我需要做什么才能获得此通知计划?

您可以使用以下代码发送延迟5分钟的本地通知:

NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
NSDate *currentDate = [NSDate date];
[dateComponents setMinute:5];
NSDate *fireDate = [gregorian dateByAddingComponents:dateComponents toDate:currentDate options:0];

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

// Configure the notification
// ....
//

localNotification.fireDate = fireDate;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

但是我认为你需要做的是使用
NSTimer
或者简单地使用
performSelector:withObject:afterDelay:
方法
NSObject

你可以尝试本地通知。看看这个,好的,我会看看我是否可以使用这个教程,你的代码在哪里注册通知,尝试本地通知,在u中可以设置点火时间。是的,将其添加到您的函数中,或者添加到需要安排通知的任何位置。
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
NSDate *currentDate = [NSDate date];
[dateComponents setMinute:5];
NSDate *fireDate = [gregorian dateByAddingComponents:dateComponents toDate:currentDate options:0];

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

// Configure the notification
// ....
//

localNotification.fireDate = fireDate;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];