zoukankan      html  css  js  c++  java
  • 本地通知UILocalNotification

    /*

     本地通知(UILocalNotification)  操作流程:

     1、接收通知

     - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

     

     //     接收到通知 之后的操作

     

     }

     

     2、注册 发送通知(需注意iOS8 之后的改动)

     提示事件

     闹钟

     

     

     */

     

     

    #import "ViewController.h"

     

     

    @interface ViewController ()

     

    @end

     

    @implementation ViewController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

     

     

    }

     

    //- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //    

    //    [self pushNotifation];

    //

    //    return YES;

    //}

     

    //

    ////     接收本地通知

    //- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

    //    

    ////     接收到通知 之后的操作

    //    NSLog(@"接收到通知 之后 %@", notification.userInfo);

    //    

    //    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:notification.alertTitle message:notification.alertBody delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //    [alert show];

    //    

    //}

    //

    //

    //- (void)pushNotifation {

    //    

    ////  注册 发送通知

    //    /**

    //     初始化本地通知方法

    //     */

    //    UILocalNotification *not = [[UILocalNotification alloc] init];

    ////    启动的时间  fireDate

    ////    TimeInterval 时间单位是 秒

    //    not.fireDate = [NSDate dateWithTimeIntervalSinceNow:1];

    ////    设置通知标题

    //    not.alertTitle= @"时间到";

    ////    设置通知的 内容

    //    not.alertBody = @"该起床了,太阳都晒到屁股了";

    ////    通过通知 传递内容

    //    not.userInfo = @{@"key":@"send infomation"};

    ////    设置 app 图标上面的“红点显示的”数字

    //    not.applicationIconBadgeNumber = 1;

    //    

    //    

    //    /*

    //     NSCalendarUnitEra                = kCFCalendarUnitEra,一个世纪

    //     NSCalendarUnitYear               = kCFCalendarUnitYear, 一年

    //     NSCalendarUnitMonth              = kCFCalendarUnitMonth, 一个月

    //     NSCalendarUnitDay                = kCFCalendarUnitDay, 天

    //     NSCalendarUnitHour               = kCFCalendarUnitHour, 时

    //     NSCalendarUnitMinute             = kCFCalendarUnitMinute,分

    //     NSCalendarUnitSecond             = kCFCalendarUnitSecond,秒

    //     NSCalendarUnitWeekday            = kCFCalendarUnitWeekday, 一个礼拜

    //     NSCalendarUnitWeekdayOrdinal     = kCFCalendarUnitWeekdayOrdinal,

    //     */

    //    not.repeatInterval = kCFCalendarUnitDay;    //  一天提示一次

    //    

    ////    注册通知

    ////    判断是否可以相应 某个方法

    ////    [self respondsToSelector:<#(SEL)#>];

    //  

    //    /*

    //     UIUserNotificationTypeNone

    //     UIUserNotificationTypeBadge 圆圈内提示的数字

    //     UIUserNotificationTypeSound  通知提示的声音

    //     UIUserNotificationTypeAlert   振动

    //     */

    //    if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {

    //        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeNone |

    //                                                                            UIUserNotificationTypeBadge |

    //                                                                             UIUserNotificationTypeSound |

    //                                                                            UIUserNotificationTypeAlert  categories:nil]];

    //    }

    //    not.soundName = UILocalNotificationDefaultSoundName;

    //    

    //    

    ////     发送通知

    //    [[UIApplication sharedApplication] scheduleLocalNotification:not];

    //

    //    

    //    

    //}

     

  • 相关阅读:
    java 项目的CAS搭建
    OpenStack Grizzly版本(Ubuntu 12.04)配置
    存储介质管理
    软件包管理
    终端和键盘
    Shell环境(environment)和配置(configuration)
    Linux 基本命令入门
    iptables的原理及使用
    移动小球 (sicily 1934) (双向链表)
    1010 Tempter of the Bone (杭电) (图Graph)
  • 原文地址:https://www.cnblogs.com/wukun16/p/4884159.html
Copyright © 2011-2022 走看看