开发者

Recurring alarm in iphone app

开发者 https://www.devze.com 2023-03-29 12:58 出处:网络
I am making an iphone app, in which there is one alarm implementation module. In this alarm implementation I have to set alarm, and this alarm can be number of times in a day at different times and ca

I am making an iphone app, in which there is one alarm implementation module. In this alarm implementation I have to set alarm, and this alarm can be number of times in a day at different times and can be for a number of days. I want to use the calendar API for it. How can I set alarm by using calendar API. How can I im开发者_运维问答plement this concept. If some one know about this concept. Please help me.

Thanks in advance.


Im assuming you want a push notification of some sort? Like a UIAlertView. This is called a UILocalNotification.

UILocalNotification *localNotif = [[UILocalNotification alloc]init];
[localNotif setFireDate:[NSDate dateWithTimeInterval:10.0f sinceDate:[NSDate new]]]; // the date to fire
[localNotif setAlertAction:@"Test"]; // title
[localNotif setAlertBody:@"This is a test"]; // tells you what to put in the description
[localNotif setRepeatInterval: NSWeekCalendarUnit]; // repeat interval, what you asked for
[[UIApplication sharedApplication]scheduleLocalNotification:localNotif]; // put it into the application
[localNotif release];

This fires a notification in ten seconds and repeats it on a weekly basis from the date you specified(I believe so please comment if im wrong fellow programmers).

You are bound to these options

NSEraCalendarUnit NSYearCalendarUnit NSMonthCalendarUnit NSDayCalendarUnit NSHourCalendarUnit NSMinuteCalendarUnit NSSecondCalendarUnit NSWeekCalendarUnit NSWeekdayCalendarUnit NSWeekdayOrdinalCalendarUnit NSQuarterCalendarUnit


can be no of times in a day at different time and can be for no of days

What on earth does that mean?

I dont fully understand what you are referring too.

FYI, take a look at this: http://developer.apple.com/library/iOS/#documentation/UIKit/Reference/UIDatePicker_Class/Reference/UIDatePicker.html

0

精彩评论

暂无评论...
验证码 换一张
取 消