根據 [[UIApplication sharedApplication] enabledRemoteNotificationTypes] 的返回值來進行判斷,該返回值是一個枚舉值,如下:
typedef enum {
UIRemoteNotificationTypeNone = 0,
UIRemoteNotificationTypeBadge = 1 << 0,
UIRemoteNotificationTypeSound = 1 << 1,
UIRemoteNotificationTypeAlert = 1 << 2,
UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3,
} UIRemoteNotificationType;
如果是 UIRemoteNotificationTypeNone ,則可以認爲推送開關沒有打開,反之亦然。
//獲取到
系統通知中心的設置
UIRemoteNotificationType type = [[UIApplication
sharedApplication] enabledRemoteNotificationTypes];