• iOS


    (iOS8中 用户开启的推送通知类型 对应的是 UIUserNotificationType (下边代码中 UIUserNotificationSettings 的types属性的类型) ,iOS7对应的是UIRemoteNotificationType)

    那么如何获得呢,在iOS8中是通过types属性,[[UIApplication sharedApplication] currentUserNotificationSettings].types

    如果用户没有允许推送,types的值必定为0

    1 /**
     2  *  check if user allow local notification of system setting
     3  *
     4  *  @return YES-allowed,otherwise,NO.
     5  */
     6 + (BOOL)isAllowedNotification {
     7     //iOS8 check if user allow notification
     8     if ([UIDevice isSystemVersioniOS8]) {// system is iOS8
     9         UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
    10         if (UIUserNotificationTypeNone != setting.types) {
    11             return YES;
    12         }
    13     } else {//iOS7
    14         UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    15         if(UIRemoteNotificationTypeNone != type)
    16             return YES;
    17     }
    18     
    19     return NO;
    20 }

    下面这个方法我是添加在UIDecive的Category中的,用于判断当前系统版本是大于iOS8还是小于iOS8的

     1 /**
     2  *  check if the system version is iOS8
     3  *
     4  *  @return YES-is iOS8,otherwise,below iOS8
     5  */
     6 + (BOOL)isSystemVersioniOS8 {
     7     //check systemVerson of device
     8     UIDevice *device = [UIDevice currentDevice];
     9     float sysVersion = [device.systemVersion floatValue];
    10     
    11     if (sysVersion >= 8.0f) {
    12         return YES;
    13     }
    14     return NO;
    15 }
  • 相关阅读:
    开博说两句
    学习总结 (持续更新)
    ip代理 120203
    [vs2005]关于预编绎网站的问题[已预编译此应用程序的错误]
    JAVA类基础
    集合类和泛型
    IO流——字符流
    多线程和包
    多态和内部类
    抽象类与接口
  • 原文地址:https://www.cnblogs.com/blogfantasy/p/5213168.html
Copyright © 2020-2023  润新知