IOS使用本地通知(UILocalNotification)删除应用角标小红点不删除通知中心内容
来源:互联网 发布:图标修复软件 编辑:程序博客网 时间:2024/06/16 11:51
1.本地通知需要当应用在后台时执行,比如放在applicationDidEnterBackground方法里;
2.需要注册通知
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[self notificationSetting];return YES;}/** *推送设置 */-(void)notificationSetting{ // ios8后,需要添加这个注册,才能得到授权 if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { UIUserNotificationType type = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound; UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:type categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; }}- (void)applicationDidEnterBackground:(UIApplication *)application { [self execLocalNofitication];}-(void)execLocalNofitication{ UILocalNotification *notification = [[UILocalNotification alloc] init]; if (notification) { // 设置触发通知的时间 NSDate *fireDate = [NSDate dateWithTimeIntervalSinceNow:2]; notification.fireDate = fireDate; // 时区 notification.timeZone = [NSTimeZone defaultTimeZone]; // 设置重复的间隔 notification.repeatInterval = 0; // 通知内容 notification.alertBody = nil; notification.applicationIconBadgeNumber = -99; // 通知被触发时播放的声音 notification.soundName = nil; // 执行通知注册 [[UIApplication sharedApplication] scheduleLocalNotification:notification]; }}
0 0
- IOS使用本地通知(UILocalNotification)删除应用角标小红点不删除通知中心内容
- UILocalNotification 本地通知无法删除的坑
- iOS本地通知UILocalNotification
- IOS 本地通知 UILocalNotification
- ios本地通知UILocalNotification
- iOS UILocalNotification本地通知
- iOS本地通知:UILocalNotification
- iOS本地通知:UILocalNotification
- iOS UILocalNotification本地通知
- iOS本地通知:UILocalNotification
- iOS本地通知:UILocalNotification
- iOS UILocalNotification本地通知
- iOS本地通知 UILocalNotification
- iOS 本地通知:UILocalNotification
- iOS: 本地通知(UILocalNotification )的应用
- IOS本地通知(UILocalNotification)的基本使用
- iOS本地通知推送使用:UILocalNotification
- ios推送:本地通知UILocalNotification
- 213 lab 4 cachelab
- 安装虚拟机
- 你应该知道的RPC原理
- KMP算法中next数组的求取
- Ubuntu16.04 LTS 上查找Django源文件的位置
- IOS使用本地通知(UILocalNotification)删除应用角标小红点不删除通知中心内容
- 文章标题
- 巨杉应用案例:大数据司法查询平台
- MarkDown图片大小处理
- 多线程与静态方法及其中的局部变量关系
- Android -- 字符和数字的判断
- Android性能优化精华帖(持续更新...)
- kafka常用操作(不定期更新)
- iOS 视频添加滤镜资料之三