ios 添加本地通知

在Appdelegate.m的回调函数

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    NSDate *alertTime = [[NSDate date]
          dateByAddingTimeInterval:10];
    UIApplication* app = [UIApplication sharedApplication];
    UILocalNotification* notify = [[UILocalNotification alloc]
          init];
    if (notify)
    {
        notify.fireDate = alertTime;
        notify.timeZone = [NSTimeZone defaultTimeZone];
        notify.repeatInterval = 0;
        notify.soundName = @"bell_tree.mp3";
        notify.alertBody = @"Staff meeting in 30 minutes";
        [app scheduleLocalNotification:notifyAlarm];
    }
}

posted on 2014-01-09 10:26  小白说我是2B  阅读(277)  评论(0编辑  收藏  举报

导航