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 8726985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:21:24+00:00 2026-06-13T08:21:24+00:00

I have set UILocalNotification according UISWitch position by calling following method on button action

  • 0

I have set UILocalNotification according UISWitch position by calling following method on button action set alarm.

- (void)scheduleNotificationWithInterval:(int)minutesBefore {

    NSDateFormatter* theDateFormatter = [[NSDateFormatter alloc] init];
    [theDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
    [theDateFormatter setDateFormat:@"EEEE"];
    NSString *currentDay=  [theDateFormatter stringFromDate:combo2.datePick.date];

    [[UIApplication sharedApplication] cancelAllLocalNotifications];

    UILocalNotification *localNotif = [[UILocalNotification alloc] init];
    if (localNotif == nil)
        return;
    localNotif.fireDate = [combo2.datePick.date dateByAddingTimeInterval:-30];
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    localNotif.repeatInterval=NSCalendarCalendarUnit;
    localNotif.repeatInterval = NSDayCalendarUnit;

    if (iBOfSwitchAlarm.on) {

        if([combo1.selectedText isEqualToString:currentDay])
        {

            NSLog(@"In DayCheck");
            localNotif.alertBody = @"Alarm Test";
            localNotif.alertAction = @"Ok";
            localNotif.soundName = UILocalNotificationDefaultSoundName;

            NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"THere Message for Alarm" forKey:@"Message"];
            localNotif.userInfo = infoDict;

            [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
        }
    }else{
        NSLog(@"SwOff");
    }
}

I write following code in AppDelegate. Here also i check switch position.

ViewController *obj =[[ViewController alloc]init];

    NSString *itemName = [notif.userInfo objectForKey:@"Message"];

    if (obj.iBOfSwitchAlarm.on) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alarm Title" message:itemName delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Continue", nil];
        alertView.tag = 1111;
        [alertView show];

        app.applicationIconBadgeNumber = notif.applicationIconBadgeNumber-1;
    }else{
       NSLog(@"SwitchOff");
    }

Now my problem is when I set Notification according to time. It is getting alert on time. But in between when i make Switch OFF and again ON it is not getting alert. There is any way to make On and Off notification according to switch position. Please help me if any one knows. Thanks in advance.

  • 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-13T08:21:24+00:00Added an answer on June 13, 2026 at 8:21 am

    to turn off you notification you can use [[UIApplication sharedApplication] cancelAllLocalNotifications]; or for specific [[UIApplication sharedApplication] cancelLocalNotification:<#(UILocalNotification *)#>];
    and then you will have to reschedule your notification like this

    [[MKLocalNotificationsScheduler sharedInstance] scheduleNotificationOn:[[NSDate Date] addTimeInterval:60*60*24*1]
                                                                      text:@"Hi this is notification"
                                                                    action:@"View"
                                                                     sound:@"Raising_Sound.mp3"
                                                               launchImage:nil
                                                                   andInfo:nil];
    

    In my case i am rescheduling for one day later

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UILocalNotification that is set to start at 2012-06-18 10:00 with a
I have set up an app that is registered for remote notifications. - (void)application:(UIApplication*)application
I have set up a datepicker in a form using the following js: $(#Expiry).datepicker({
I have set up the following animation to rotate between views of different sizes.
We have set the following app settings to be iPhone only, but in the
I have prepared an Alarm Clock app which uses UILocalnotification for scheduling the alarm.Now
I have a UILocalNotification set up, and as far as i can see it
I have a method that activates a local notification. UILocalNotification *localNotif = [[UILocalNotification alloc]
I have set of categories (the number of which changes according to specific state)
I have set up a openVPN tunnel using the following server side configuration: port

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.