applicationIconBadgeNumber和localNotification申请通知弹出
2015-12-19 23:22
330 查看
在application代理中添加如下加粗方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)])
{
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)])
{
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
return YES;
}
#import "ViewController.h" @interface ViewController () - (IBAction)noti:(UIButton *)sender; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; } - (IBAction)noti:(UIButton *)sender { UILocalNotification *noti = [[UILocalNotification alloc]init]; noti.fireDate = [NSDate dateWithTimeIntervalSinceNow:5]; noti.alertBody = @"alertBody"; noti.alertAction = @"alertAction"; noti.applicationIconBadgeNumber = 4; UIApplication *app = [UIApplication sharedApplication]; [app cancelAllLocalNotifications]; [app scheduleLocalNotification:noti]; } @end
相关文章推荐
- 加速Gradle构建项目
- 报错:Could not find method android.view.ViewTreeObserver.removeOnGlobalLayoutListener
- 在Unity中接入Xbox360手柄
- Android 之一张图片搞定数据加载进度条+各种颜色效果,任性的不得了
- Android开发必知的50个诀窍之一
- DSOJ Placing apples(放苹果)
- IOS开发之文本复制
- IOS 开发中相机获取图片 不同方向的相机获取不同的图片的实现 ||图片的从新绘图
- iOS学习:调用相机,选择图片上传,带预览功能
- 战神答题APP 无敌结束版
- 蓝懿iOS 技术内容和心得 12.19
- [Android Studio] Gradle
- swift控件之旅之UILabel
- iOS单元测试
- Handler消息传递机制一
- Android Studio搭建Android集成开发环境
- android中滚动方法的讲解
- Android动画--视图动画
- android中广播的使用
- Android AbsListView坐标体系解析