Edi
Edi

Reputation: 1768

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?

Upvotes: 3

Views: 3762

Answers (2)

xhan
xhan

Reputation: 6307

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);

Upvotes: 0

Himanshu Mohan
Himanshu Mohan

Reputation: 732

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.

Upvotes: 4

Related Questions