iOS 推送
2015-06-09 17:09
381 查看
// 将旧的推送从通知中心移除
[application setApplicationIconBadgeNumber:0];
#if !TARGET_IPHONE_SIMULATOR
// iOS8 注册推送
if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {
UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[application registerForRemoteNotifications];
[application registerUserNotificationSettings:settings];
}
// iOS7 and before 注册推送
else {
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
#endif
参考:http://www.blogjava.net/xiaomage234/archive/2014/06/18/414895.html
[application setApplicationIconBadgeNumber:0];
#if !TARGET_IPHONE_SIMULATOR
// iOS8 注册推送
if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {
UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[application registerForRemoteNotifications];
[application registerUserNotificationSettings:settings];
}
// iOS7 and before 注册推送
else {
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
#endif
参考:http://www.blogjava.net/xiaomage234/archive/2014/06/18/414895.html
相关文章推荐
- iOS中数据持久存储方式及区别
- ios简单动画的实现
- IOS8 设置TableView分割线
- IOS8开发技术之自动布局
- ios项目删除Git
- iOS下截屏的几种方法
- IOS开发获取路径的方法
- iOS9开发者测试版下载地址(系转载)
- IOS-PPRevealViewController侧边栏
- iOS 正则表达式
- iOS单例设计模式详解教程
- iOS-集成环信
- iOS基础——浅谈个人对协议、代理的理解
- iOS真机测试初次体验
- ios开发学习笔记(1)
- 一步一步学习iOS 摘记
- iOS代码适配(2)
- iOS开发多线程篇—GCD介绍
- IOS 沙盒(sandbox)机制和文件操作
- [iOS diary]CABasicAnimation KeyPath大全与使用事例