zoukankan      html  css  js  c++  java
  • Scheduling the Delivery of Local Notifications

    Scheduling the Delivery of Local Notifications

      Apps can use local notifications to display alerts, play sounds, badge the app’s icon, or a combination of the three. For example, an alarm clock app might use local notifications to play an alarm sound and display an alert to disable the alarm. When a notification is delivered to the user, the user must decide if the information warrants bringing the app back to the foreground. (If the app is already running in the foreground, local notifications are delivered quietly to the app and not to the user.)

      Your own apps can have no more than 128 local notifications active at any given time, any of which can be configured to repeat at a specified interval.

     1 // Listing 3-4  Scheduling an alarm notification
     2 - (void)scheduleAlarmForDate:(NSDate*)theDate
     3 {
     4     UIApplication* app = [UIApplication sharedApplication];
     5     NSArray*    oldNotifications = [app scheduledLocalNotifications];
     6  
     7     // Clear out the old notification before scheduling a new one.
     8     if ([oldNotifications count] > 0)
     9         [app cancelAllLocalNotifications];
    10  
    11     // Create a new notification.
    12     UILocalNotification* alarm = [[UILocalNotification alloc] init];
    13     if (alarm)
    14     {
    15         alarm.fireDate = theDate;
    16         alarm.timeZone = [NSTimeZone defaultTimeZone];
    17         alarm.repeatInterval = 0;
    18         alarm.soundName = @"alarmsound.caf";
    19         alarm.alertBody = @"Time to wake up!";
    20  
    21         [app scheduleLocalNotification:alarm];
    22     }
    23 }
  • 相关阅读:
    zigbee芯片
    笔记本ubuntu安装wifi驱动(未完成)
    我错了的N个学习
    《华为工作法》读书笔记
    bbblack的网络socket通信实验
    NB-IOT连接移动onenet平台流程
    移动onenet基础通信套件V1.08版本的AT指令测试
    CC3200使用MQTT的SSL加密证书可用日期修改
    利尔达NB-IOT模块烧写固件的步骤
    树莓派相机
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3741465.html
Copyright © 2011-2022 走看看