Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:12:55+00:00 2026-06-02T22:12:55+00:00

I have this piece of code which I use for firing a local notification

  • 0

I have this piece of code which I use for firing a local notification each day at mid night:

//Get todays midnight
    NSDate *alertTime = [NSDate date];
    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
    NSUInteger preservedComponents = (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit);
    alertTime = [calendar dateFromComponents:[calendar components:preservedComponents fromDate:alertTime]];

    UIApplication *app = [UIApplication sharedApplication];

    //Set up the local notification
    UILocalNotification *notification = [[UILocalNotification alloc] init];
    if(notification){
        //Set fire date to alert time
        notification.fireDate = alertTime;
        //Set time zone to default
        notification.timeZone = [NSTimeZone defaultTimeZone];
        //Repeat the notification everyday (fires at same time
        //as initial notification)
        notification.repeatInterval = NSDayCalendarUnit;

        // schedule notification
        [app scheduleLocalNotification:notification];

        NSLog(@"%@", notification.fireDate);
    }

However I need another local notification to fire each day at 13:00. How is this accomplished? I don’t understand how the above code can be adapted to achieve this..

Thanks a lot,

Jack

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:12:59+00:00Added an answer on June 2, 2026 at 10:12 pm

    If you have the time which you have to fire notification every day, you should do this

    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
        NSDateComponents *components = [[NSDateComponents alloc] init];
        for (NSMutableArray * arrDay in self.namaztimes) {
            NSLog(@"Alarm Array: %@", arrDay);
            int count=[arrDay count];
            if(!count){
                continue;
            }
    
            int day =0;
            int month=0;
            int year=0;
            int hour =0;
            int minutes=0;
    
            //  NSArray *arrDates=[[NSMutableArray alloc] initWithCapacity:1];
            for ( int i=0;i<3;i++) {
                NSString * dayTime=[arrDay objectAtIndex:i ];
                if (i==0) {
                    day = [dayTime intValue];    
                }else if(i==1){
                    month = [dayTime intValue];                    
                }else if(i==2){
                    year = [dayTime intValue];    
    
                }
            }
            for ( int i=3;i<count;i++) {
                NSString * dayTime=[arrDay objectAtIndex:i ];
                hour = [[dayTime substringToIndex:2] intValue];
                minutes = [[dayTime substringFromIndex:3] intValue];
    
                [components setDay:day];
                [components setMonth:month];
                [components setYear:year];
                [components setMinute:minutes];
                [components setHour:hour];
    
    
                NSDate *myNewDate = [calendar dateFromComponents:components];
    
                [self scheduleNotificationForDate:myNewDate];
    
            }
        }
    
        [components release];
        [calendar release];
    

    then from here it will connect to the main notification firing method
    [self scheduleNotificationForDate:myNewDate];

    -(void) scheduleNotificationForDate: (NSDate*)date {
        /* Here we cancel all previously scheduled notifications */
        [[UIApplication sharedApplication] cancelAllLocalNotifications];
        UILocalNotification *localNotification = [[UILocalNotification alloc] init];
        localNotification.fireDate = date;
        NSLog(@"Notification will be shown on: %@ ",localNotification.fireDate);
    
        localNotification.timeZone = [NSTimeZone defaultTimeZone];
        localNotification.alertBody = @"Your Notification Text"; //[NSString stringWithFormat:@"%@",date];
        localNotification.alertAction = NSLocalizedString(@"View details", nil);
    
        /* Here we set notification sound and badge on the app's icon "-1" 
         means that number indicator on the badge will be decreased by one 
         - so there will be no badge on the icon */
    
        localNotification.repeatInterval = NSDayCalendarUnit;
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        localNotification.applicationIconBadgeNumber = -1;
    
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code which I'm hoping will be able to tell
I am somewhat new to R, and i have this piece of code which
Ok i have this piece of code from which i took from W3schools :-
I have this piece of Open MP code here which performs an integeration of
I have this piece of code: if(($op == q)); then which throws out this
I have this piece of code: $(#faq).click(function () { var url = $.get(faq, {
I have this piece of code which works 90% of the time: $user_details=$fb->api_client->users_getInfo($fb_user, array('last_name','first_name','proxied_email'));
I have a problem with this piece of code If I don't use the
I have a piece of C# code in which I use the goto statement.
I have this piece of code which i am using on another area of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.