我创建了UISwitch以启用/禁用iOS 7和iOS 8都应该支持的推送通知。我试图弄清楚如何在iOS 8中使用它。无法确定要填写的内容以下空白:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
.......... fill in here...for iOS 8.........................
}
else
{
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
BOOL turnedOffFromWithinNotificaitonCenter = (types == UIRemoteNotificationTypeNone);
if (turnedOffFromWithinNotificaitonCenter){
_remindersSwitch.on = FALSE;
}
else{
_remindersSwitch.on = TRUE;
}
}
任何建议都表示赞赏。感谢。
答案 0 :(得分:0)
通知现在使用UIUserNotificationSettings
对象来封装此类信息。这些类型仍然包含在那里。因此,空白'将是:
UIUserNotificationSettings* currentSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
UIUserNotificationType enabledTypes = currentSettings.types;
BOOL turnedOffFromWithinNotificaitonCenter = ((enabledTypes & UIUserNotificationTypeNone) == UIUserNotificationTypeNone);
if (turnedOffFromWithinNotificaitonCenter){
_remindersSwitch.on = FALSE;
}
else{
_remindersSwitch.on = TRUE;
}