iOS本地通知——每天固定时间发送通知
来源:互联网 发布:mac 建筑 软件 免费 编辑:程序博客网 时间:2024/05/22 03:25
+ (void)registerLocalNotification{名字瞎取得不要在意这些细节。。
UILocalNotification *notification = [[UILocalNotificationalloc]init];
// 设置触发通知的时间
时间注意,since1970得到的是格林尼治时间早八点,所以需要几点通知算一下,你懂得,如下13*60*60代表延后13个小时也就是晚上21点
NSDate *fireDate = [NSDatedateWithTimeIntervalSince1970:13*60*60];
notification.fireDate = fireDate;
// 时区
notification.timeZone = [NSTimeZonedefaultTimeZone];
// 设置重复的间隔
自行设定间隔思密达
notification.repeatInterval =NSCalendarUnitDay;
// 通知内容
notification.alertBody = @"你今天学习了嘛";
设置程序图标小红点数字,不知为何用++ \+=都只保持1,不过这并不重要(大概。。。
notification.applicationIconBadgeNumber +=1;
// 通知被触发时播放的声音
notification.soundName =UILocalNotificationDefaultSoundName;
// 通知参数
NSDictionary *userDict = [NSDictionarydictionaryWithObject:@"test"forKey:@"key"];
notification.userInfo = userDict;
// 执行通知注册
[[UIApplicationsharedApplication]scheduleLocalNotification:notification];
}
iOS8后请加如下语句,可以在程序启动就请求授权,也可以按需加到自己需要获取授权的时候
//授权
UIUserNotificationType type = UIUserNotificationTypeAlert |UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettingssettingsForTypes:typecategories:nil];
[[UIApplicationsharedApplication]registerUserNotificationSettings:settings];
转自 http://blog.csdn.net/qq_35880238/article/details/52213778
- iOS本地通知——每天固定时间发送通知
- iOS本地通知——每天固定时间发送通知
- iOS本地通知——每天固定时间发送通知
- iOS发送本地通知
- iOS开发本地通知(每天定点发送消息推送)
- iOS 通知——本地通知
- ios-王云鹤 发送本地通知
- iOS 每天凌晨发送通知更新界面
- iOS 本地通知 远程通知
- iOS本地通知 远程通知
- iOS本地通知&定时通知
- iOS 设置每天下午4点推送本地通知
- iOS 设置每天下午4点推送本地通知
- iOS实现本地通知
- iOS本地通知
- iOS本地通知
- iOS本地通知UILocalNotification
- IOS实现本地通知
- css 背景图片模糊 上面内容不模糊
- ubuntu 安装cuda driver失败的问题
- 913课堂笔记
- Hawq学习笔记 --- 清空数据库中表的数据
- ubuntu16.04安装iNode客户端心得总结
- iOS本地通知——每天固定时间发送通知
- 使用git建立远程仓库,让别人git clone 下来
- Sublime Text3 完美配置
- [程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#1
- javaWeb Cache技术――OSCache
- 抽象
- 模拟网页点击事件
- Android,底部导航+viewpager+fragment+drawerlayout+toolbar+recyclerview
- Python与C++,SWIG