AppDelegate 中添加方法:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSLog(@"notification = %@",notification);
[application setApplicationIconBadgeNumber:0];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSLog(@"notification = %@",notification);
[application setApplicationIconBadgeNumber:0];
}
VC中推送操作:
UILocalNotification *localNotification = [[UILocalNotification alloc]init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5]; // 5秒钟之后执行
localNotification.alertBody = @"你个猪头"; //提示内容
localNotification.alertAction = @"猪猪"; //设置确认按钮的标题
localNotification.alertLaunchImage = @"link_page_1"; // 设置启动图片
localNotification.soundName = @"管钟琴.caf"; //提示音效
localNotification.applicationIconBadgeNumber = 10;
localNotification.repeatInterval = NSCalendarUnitSecond;//每秒
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; // 调用本地通知
//取消推送
//[[UIApplication sharedApplication] cancelLocalNotification:notification];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5]; // 5秒钟之后执行
localNotification.alertBody = @"你个猪头"; //提示内容
localNotification.alertAction = @"猪猪"; //设置确认按钮的标题
localNotification.alertLaunchImage = @"link_page_1"; // 设置启动图片
localNotification.soundName = @"管钟琴.caf"; //提示音效
localNotification.applicationIconBadgeNumber = 10;
localNotification.repeatInterval = NSCalendarUnitSecond;//每秒
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; // 调用本地通知
//取消推送
//[[UIApplication sharedApplication] cancelLocalNotification:notification];