开发者

Repeat UILocalNotification on certain days of week

I want to customize the repeat interval of a UILocalNotification to be on certain days of the week. I haven't 开发者_开发百科found any information about this.

How can I program the repeat interval for notifications for certain days of the week, for example, repeat a notification on Sunday, Monday, and Friday?


Unfortunately you cannot set the repeatInterval property of UILocalNotification to repeat only on particular days. You can set either repeat daily (every day), monthly (every month) or hourly (every hour). So the only feasible solution for your question is that if you want to set an alarm on Sunday, Monday and Tuesday then you have to set 3 alarms (one each for Sunday ,Monday and Tuesday) rather than one alarm.


If you need to custom repeatInterval property. You have to setup each UILocalNotification on specify time. here is my codes.


    void (^insertAlarm)(NSDate*fire,NSString*sound,int alarmCount) = ^(NSDate*fire,NSString*sound,int alarmCount){
        UILocalNotification* notification = [[UILocalNotification alloc] init];
        notification.timeZone = [NSTimeZone defaultTimeZone];
        notification.soundName = sound;
        notification.fireDate = fire;
        notification.repeatInterval = 0;
        notification.alertLaunchImage = IMG;
        notification.alertAction = ACTION_MSG;        
        notification.alertBody = BODY;
        notification.applicationIconBadgeNumber = 1;
        [[UIApplication sharedApplication] scheduleLocalNotification:notification];
        [notification release];
    };

    insertAlarm(date,sound.fileName,0);
    insertAlarm([date dateByAddingTimeInterval:60],sound.fileName,1);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜