方案如下:
根据 [[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 ,则可以认为推送开关没有打开,反之亦然。