我如何能实现"贪睡"在iOS中? [英] How can i implement "snooze" in iOS?

查看:285
本文介绍了我如何能实现"贪睡"在iOS中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个闹钟应用和实施,如贪睡功能。

I want to develop an alarm app and implement like "snooze" feature.

首先,用户使用日期选择设置时间。安当用户忽略的通知,

First, user set the time using datePicker. ann when user ignores the notification,

这5分钟后再次推通知。

it pushes notification again after 5 mins.

所以我用UILocalNotification并设置按repeatInterval = NSDayCalendarUnit

So i used UILocalNotification and set repeatInterval = NSDayCalendarUnit

然后我可以收到通知的每一天,但我不知道如何实现贪睡

then i can receive the notification every day but i don't know how to implement "snooze"

只有当用户忽略了第一个通知。

only when user ignores the first notification.

推荐答案

您可以安排多达64个本地通知。

You can schedule up to 64 local notifications.

所以,你在5分钟间隔安排他们。

So schedule them with your 5 minute interval.

如果用户忽略的通知(不开你的应用程序),下通知将在5分钟内熄灭。

If the user ignores the notification (does not open your app), the next notification will go off in 5 minutes.

如果他真的打开你的应用程序,你可以通过

If he actually open your app, you can get the scheduled notification via

[[UIApplication sharedApplication] scheduledLocalNotifications];

并通过

[[UIApplication sharedApplication] cancelLocalNotification];

然后重新安排与5分钟间隔的下一个报警。

Then you reschedule for the next alarm with the 5 minute interval.

这篇关于我如何能实现"贪睡"在iOS中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆