我想知道通知中心的状态是处于“ON”还是“OFF”状态。
据我所知,每个人都说通过使用
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
但是我需要获得“ON”或“OFF”状态。
我搜索谷歌结果是:
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone)
{
}
和
if (launchOptions != nil)
{
NSDictionary* dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (dictionary != nil)
{
NSLog(@"Launched from push notification: %@", dictionary);
[self clearNotifications];
}
}
和
if (notificationTypes == UIRemoteNotificationTypeNone) {
// Do what ever you need to here when notifications are disabled
} else if (notificationTypes == UIRemoteNotificationTypeBadge) {
// Badge only
} else if (notificationTypes == UIRemoteNotificationTypeAlert) {
// Alert only
} else if (notificationTypes == UIRemoteNotificationTypeSound) {
// Sound only
} else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)) {
// Badge & Alert
} else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)) {
// Badge & Sound
} else if (notificationTypes == (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)) {
// Alert & Sound
} else if (notificationTypes == (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)) {
// Badge, Alert & Sound
}
但我没有得到 ios5 和 ios6 的结果
请指导我
提前致谢