iphone - 如何在 iPhone 中创建一段时间的提醒,例如 30 分钟后提醒我

标签 iphone objective-c notifications push-notification uilocalnotification

您好,我正在开发提醒应用程序。

我需要在某个特定时间后显示提醒。

但不是我们在日期选择器中设置的时间。

就像我有一个“10 分钟后提醒”按钮一样

-(IBAction)ReminderClick:(id)sender
{
}

当用户按下按钮时,10 分钟后需要显示警报。

最佳答案

您需要为此功能使用 UILocalNotification 代码看起来像

UIApplication* app = [UIApplication sharedApplication];
        UILocalNotification* notifyAlarm = [[UILocalNotification alloc] init];

        NSDate *date1=[fire dateByAddingTimeInterval:60];
        notifyAlarm.fireDate = date1;
        notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
        //notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
        notifyAlarm.repeatInterval =NSWeekCalendarUnit ;
        notifyAlarm.soundName =soundString;
        notifyAlarm.alertBody =snoozeBody;
        notifyAlarm.userInfo=snoozeDict;
        //notifyAlarm.alertLaunchImage=@"in.png";
        [app scheduleLocalNotification:notifyAlarm]; 

并且您可以按照这些教程进行操作 http://www.icodeblog.com/tag/uilocalnotification/

http://blog.mugunthkumar.com/coding/iphone-tutorial-scheduling-local-notifications-using-a-singleton-class/

http://www.iostipsandtricks.com/ios-local-notifications-tutorial/

http://www.youtube.com/watch?v=tcVoq488-XI

关于iphone - 如何在 iPhone 中创建一段时间的提醒,例如 30 分钟后提醒我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10328168/

相关文章:

iphone - 从 UIBarButtonItem 获取 UIBarButtonSystemItem

objective-c - 优化扫描大文本并匹配单词或短语列表

objective-c - 将 NSWindow 放在前面但不放在焦点上

iphone - MPMediaItem 如何播放?

javascript - 当浏览器在后台运行时收到通知时使用 Firebase 播放声音

iphone - Xcode 4 测试构建类冲突

ios - UIPageViewController : partial display when swiping right

iphone - 核心情节: bars disappears when switching app to background and then to foreground while drawing a bar graph

android - 如何在应用程序运行时停止通知?

ios - 接收iOS系统(例如短信)通知