iPhone 本地通知

UILocalNotification *notice = [[UILocalNotification alloc] init];  
   
if (notice != nil)
    {
       
// 5秒后通知
        notice.fireDate = [[NSDate date] addTimeInterval:5.0];
       
       
// 循环次数,kCFCalendarUnitWeekday 一周一次
       
// 这里是 0, 不循环。
        notice.repeatInterval = 0;
       
       
       
// 时区, 可以不用设置,默认为手机设置时区。
        notice.timeZone = [NSTimeZone defaultTimeZone];
       
       
       
// 桌面 icon 上的数字提示。默认是0,不会显示。
        notice.applicationIconBadgeNumber = 1;
       
       
       
// 弹出通知时的音效,可以换成alarm.soundName = @"xxx.caf"
       
// 这里是默认音效
        notice.soundName = UILocalNotificationDefaultSoundName;
       
       
       
// 通知的内容。 必须要设置,否则不会弹出通知。
        notice.alertBody = @"我是一个本地通知";
       
       
       
// 提示框按钮。 默认是 Close 和 View。
       
// 这里自定义 View 按钮为 打开
        notice.alertAction = @"打开"
       
       
       
// 默认是YES。为 NO 时提示框按钮只显示 OK 一个,
       
// 点击无事件发生, 不会打开 app.
        notice.hasAction = YES;
       
       
       
// 添加额外的信息, 可以用来在打开 app 时判断事件类型或内容
        NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"value" forKey:@"key"];
        notice.userInfo
= infoDict;
       
       
       
// 加入到系统通知里去. 无这句不会有通知弹出。
        [[UIApplication sharedApplication] scheduleLocalNotification:notice];     
    }

原文地址:https://www.cnblogs.com/zhwl/p/2844123.html