【问题标题】:How to schedule the local notification如何安排本地通知
【发布时间】:2018-06-30 18:19:59
【问题描述】:

我正在处理戒烟申请。我想向在一段时间内不吸烟实现目标的用户显示本地通知。

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

我想安排本地通知从 20 分钟开始,到 20 年结束,并显示实现目标的消息。

如何在本地通知中实现这一点。是否可以将本地通知安排到 20 年?

【问题讨论】:

    标签: objective-c localnotification unusernotificationcenter


    【解决方案1】:

    您可以实现本地通知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];
    }
    

    是否可以将本地通知安排到 20 年?

    我不确定,但我认为它会起作用。某人使用同一部手机 20 年的可能性较小。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-06
      • 2018-04-18
      • 1970-01-01
      • 1970-01-01
      • 2018-08-08
      • 1970-01-01
      • 2012-11-26
      • 1970-01-01
      相关资源
      最近更新 更多