iOS中判断消息推送是否打开
2015-11-05 14:42
381 查看
根据 [[UIApplication sharedApplication] enabledRemoteNotificationTypes] 的返回值来进行判断,该返回值是一个枚举值,如下:
typedef enum {
UIRemoteNotificationTypeNone = 0,
UIRemoteNotificationTypeBadge = 1 << 0,
UIRemoteNotificationTypeSound = 1 << 1,
UIRemoteNotificationTypeAlert = 1 << 2,
UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3,
} UIRemoteNotificationType;
如果是 UIRemoteNotificationTypeNone ,则可以认为推送开关没有打开,反之亦然。
update
ios8以后以上方法废弃
使用
UIUserNotificationSettings *settings = [[UIApplication sharedApplication]currentUserNotificationSettings];
if (settings.types==UIUserNotificationTypeNone) {
//关闭了
}
typedef enum {
UIRemoteNotificationTypeNone = 0,
UIRemoteNotificationTypeBadge = 1 << 0,
UIRemoteNotificationTypeSound = 1 << 1,
UIRemoteNotificationTypeAlert = 1 << 2,
UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3,
} UIRemoteNotificationType;
如果是 UIRemoteNotificationTypeNone ,则可以认为推送开关没有打开,反之亦然。
update
ios8以后以上方法废弃
使用
UIUserNotificationSettings *settings = [[UIApplication sharedApplication]currentUserNotificationSettings];
if (settings.types==UIUserNotificationTypeNone) {
//关闭了
}
相关文章推荐
- RSA加密(1.0)
- IOS之NSAttributedString和NSMutableAttributedString
- iOS 简单的按钮弹出效果
- iOS 蓝牙开发(三)app作为外设被连接的实现
- iOS 9音频应用开发基础教程
- iOS block循环引用问题
- iOS 9音频应用开发基础教程(大学霸内部资料)
- iOS设备键盘的关闭和隐藏时机总结
- iOS tableView点击分区下拉单元格特效
- iOS Facebook pop动画进阶
- IOS中获取文件路径的方法
- iOS回调函数(block篇)
- iOS手势解锁
- ios开发时,在Xcode中添加多个targets进行版本控制
- 关于IOS9中NSURLConection的同步或异步发送请求过时问题。
- IOS 设置透明度导致底层View始终可见
- iOS应用程序生命周期
- iOS开发多线程篇—多线程简单介绍
- IOS之initWithFrame
- 结合自己情况聊下iOS学习建议