0

I am working on smoking quit application. I want to show local notification to user who are achieve there goals without smoking for period of time.

20 min, 12 hour, 24 hour, 1 Week, 4 week, 2 months, 5 months, 1 year, 5 year, 10 year, 20 year.

I want to schedule local notification start from 20 minutes and ends till 20 years and show achieve goal message.

How to achieve this in local notification. Is it possible to schedule local notification till 20 years?

kiran
  • 4,285
  • 7
  • 53
  • 98

1 Answers1

1

You can achieve Local notifications Like

UILocalNotification* localNotification = [[UILocalNotification alloc] init];
NSDictionary *timeInterValDict = @{
                               @"20 mint Notification" : @1200, // 20 * 60
                               @"12 hours Notification " : @43200, // 12*60*60
                               @"24 hours Notification" : @86400,  // 24 * 60 *60
                               // Like More Also You can user Date Component For Calculating Time
                               };
  for (NSString *key in timeInterValDict) {

    // Set Notification One-by-one 
    localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow: [timeInterValDict[key] doubleValue]];
    localNotification.repeatInterval = 0;
    localNotification.alertBody = key;
    localNotification.timeZone = [NSTimeZone defaultTimeZone];
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

Is it possible to schedule local notification till 20 years?

I am not sure, but I think it will work. There is less probability for someone to use the same mobile for 20 years.

Sid Singh
  • 53
  • 7