iOS 判断推送开关是否打开

方案如下:
根据 [[UIApplication sharedApplication] enabledRemoteNotificationTypes] 的返回值来进行判断,该返回值是一个枚举值,如下:

1
2
3
4
5
6
7
typedef enum {
    UIRemoteNotificationTypeNone    = 0,
    UIRemoteNotificationTypeBadge   = 1 << 0,
    UIRemoteNotificationTypeSound   = 1 << 1,
    UIRemoteNotificationTypeAlert   = 1 << 2,
    UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3,
} UIRemoteNotificationType;

如果是 UIRemoteNotificationTypeNone ,则可以认为推送开关没有打开,反之亦然。

posted @ 2013-03-05 11:20  @空空@  阅读(435)  评论(0编辑  收藏  举报