zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    C#创建Windows Service(Windows 服务)基础教程
    c#写windows服务
    怎么样快速学习AngularJS?
    Web API 安全问题
    ASP.NET Web API身份验证和授权
    通过HttpClient来调用Web Api接口~续~实体参数的传递
    在WebApi中实现Cors访问
    SQL Server 动态生成数据库所有表Insert语句
    EasyUI combobox
    Linq使用Group By 1
  • 原文地址:https://www.cnblogs.com/blogfantasy/p/5213168.html
Copyright © 2011-2022 走看看