// 1.创建通知
UILocalNotification *localNote = [[UILocalNotificationalloc] init];
//重点需要注册这个,要不没声音,没震动
if ([UIDevicecurrentDevice].systemVersion.floatValue >= 8)
{
// 这些代码在iOS8.0以前是会报错的
[[UIApplicationsharedApplication] registerUserNotificationSettings:[UIUserNotificationSettingssettingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSoundcategories:nil]];
// 2.设置属性
localNote.alertTitle=@"博唐平";
}
localNote.alertAction = @"就要接收数据了";// 操作标题
localNote.alertBody = @"还有十秒开始接收数据了,请及时进入app";// 正文
//推送声音
[localNote setHasAction:YES];
localNote.soundName =UILocalNotificationDefaultSoundName;
// localNote.soundName=@"down.mp3";
//多长时间调用一次
// localNote.repeatInterval = NSCalendarUnitMinute*3600;
localNote.alertLaunchImage = @"Default"; // 点击通知,打开程序时候现实的启动图片
//fireDate方法表示第一次调用是在什么时候
localNote.fireDate = [NSDatedateWithTimeIntervalSinceNow:5];
// 3.注册通知(添加)
UIApplication *app = [UIApplicationsharedApplication];
[app cancelAllLocalNotifications];
[app scheduleLocalNotification:localNote];