以编程方式为 NSUserActivity 创建提醒

Programmatically Create Reminder For NSUserActivity

使用 iOS 9,NSUserActivities 可以与 Siri 一起使用,例如,"Siri, remind me of this in an hour",创建提醒,让她知道 "THIS" 是什么。有没有办法以编程方式执行此操作,以便单击按钮即可创建提醒?

您可以简单地安排一个 UILocalNotification 来提醒用户:

 NSDate *dateInOneHour = [[NSDate date] dateByAddingTimeInterval:3600];

 UILocalNotification *localNotif = [[UILocalNotification alloc] init];
    localNotif.fireDate = dateInOneHour;
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    localNotif.alertBody = @"Don't forget about THIS";
    localNotif.alertAction = @"View";
    localNotif.applicationIconBadgeNumber = 1;
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];  

不是这样的答案,而是通往答案的路径:因为提醒应用程序中的提醒是由 EventKit 管理的(请参阅 https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/EventKitProgGuide/Introduction/Introduction.html),请尝试使用 Siri 制作智能提醒,然后检查生成的提醒使用 API。据猜测,它在提醒上使用了 -URL 属性。