zoukankan      html  css  js  c++  java
  • 远程推送代码的添加

    项目一添加方式;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    方法 中加入要调用的推送

    推送分iOS8来处理

    项目二添加方式;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    方法 中加入要调用的推送

    项目三添加方式;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    方法 中加入要调用的推送

    代码对比

    项目一中的推送代码

    #pragma mark XGPush
    - (void)registerPush{
        float sysVer = [[[UIDevice currentDevice] systemVersion] floatValue];
        if(sysVer < 8){
            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
        }else{
    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= _IPHONE80_
            UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategory alloc] init];
            UIUserNotificationSettings *userSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert
                                                                                         categories:[NSSet setWithObject:categorys]];
            [[UIApplication sharedApplication] registerUserNotificationSettings:userSettings];
            [[UIApplication sharedApplication] registerForRemoteNotifications];
    #endif
        }
    }

    项目二中的推送代码

    #pragma mark - 推送注册函数(并选择注册的推送消息类型)
    - (void)registerNotificationType
    {
    #ifdef  __IPHONE_8_0
        if(SystemVersion >= 8.0)
        {
            [[UIApplication sharedApplication] registerForRemoteNotifications];
            /**
             *  @author zyz
             *
             *  对应8系统后,系统推送服务
             */
            //        UIUserNotificationTypeBadge
            //        UIUserNotificationTypeSound
            //        UIUserNotificationTypeAlert
            UIUserNotificationType myTypes = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:myTypes categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        }
        else
    #endif
        {
            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
        }
    }

    项目三中的推送代码

    - (void)registerForRemoteNotifications
    {
    #if SUPPORT_IOS8
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
            UIUserNotificationType myTypes = UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound;
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:myTypes categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        }else
    #endif
        {
            UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound;
            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
        }
        /*
    #if TARGET_OS_IPHONE
    #if SUPPORT_IOS8
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
            UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:myTypes categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        }else
    #endif
        {
            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
             (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
        }
    #endif
        */
    }
    #if SUPPORT_IOS8
    - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
    {
        //register to receive notifications
        [application registerForRemoteNotifications];
    }
    #endif
  • 相关阅读:
    友元函数
    异常处理
    RTTI
    接口类
    纯虚函数和抽象类
    虚函数与虚析构函数原理
    查看表空间使用率及shrink 表空间
    RAC fail over 测试
    js判断数组中是不是有某个元素
    layui 表格图片放大
  • 原文地址:https://www.cnblogs.com/songxing10000/p/4728040.html
Copyright © 2011-2022 走看看