zoukankan      html  css  js  c++  java
  • ios 编译版本 最低版本 运行版本 动态链接库

      if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) 运行环境判断;

    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 编译器、开发环境支持;

    部署环境支持;

    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]

    在低于库版本的运行环境运行时,center返回值为nil;

    结论:

    1)在对象或类符号不存在时,动态库没有任何存在,返回值为nil;

    2)当一个类的接口存在跨系统级别的函数存在时,因为类或对象存在,函数符号不存在,所以存在崩溃的情况。

    - (void)registerRemoteNotification {

        if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {

    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 // Xcode 8编译会调用

            UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];

            center.delegate = self;

            [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionCarPlay) completionHandler:^(BOOL granted, NSError *_Nullable error) {

                if (!error) {

                    NSLog(@"request authorization succeeded!");

                }

            }];

            

            [[UIApplication sharedApplication] registerForRemoteNotifications];

    #endif

        } else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {

            UIUserNotificationType types = (UIUserNotificationTypeAlert | UIUserNotificationTypeSound | UIUserNotificationTypeBadge);

            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];

            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

            [[UIApplication sharedApplication] registerForRemoteNotifications];

        } else {

            UIRemoteNotificationType apn_type = (UIRemoteNotificationType)(UIRemoteNotificationTypeAlert |

                                                                           UIRemoteNotificationTypeSound |

                                                                           UIRemoteNotificationTypeBadge);

            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:apn_type];

        }

    }

  • 相关阅读:
    一个自动打补丁的脱机程序
    OPC 学习交流感想
    串口标准,说说流控制(RTS/CTS/DTR/DSR 你都明白了吗?)
    asp.net中调用COM组件发布IIS时常见错误 80070005解决方案
    可运行XP的最少后台服务配置
    MapGIS 7.0 SP2 企业版 & MapGIS 7.1IMS
    简单认识一下S60系统
    常用正则表达式
    图像处理:遮罩
    office2003中WORD中visio图无法打印中文问题解决方法
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8253790.html
Copyright © 2011-2022 走看看