iOS 本地通知

来源:互联网 发布:淘宝披肩外套 编辑:程序博客网 时间:2024/04/30 17:33

// 代码如下,是转载别处的,别处也是转载其他地方的,就未写明出处了。发现在xcode 5.1 的模拟器上可以测试,在xcode 6 上的模拟器就出不来,浪费了我不少的时间。

    UILocalNotification *notification=[[UILocalNotification alloc] init];

    if (notification!=nil) {

        NSLog(@">> support local notification");

        NSDate *now=[NSDate new];

        notification.fireDate=[now dateByAddingTimeInterval:3];

        notification.timeZone=[NSTimeZone defaultTimeZone];

        notification.alertBody=@"该去吃晚饭了!";

        [[UIApplication sharedApplication]   scheduleLocalNotification:notification];

    }


0 0
原创粉丝点击