zoukankan      html  css  js  c++  java
  • IOS (APP 启动 相应处理)

    APP 每次启动的入口都是通过:

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

    如果是用户自己启动的 launchOptions 是不带参数的,反之者有内容.

    若是外部启动launchOptions KEY 一般有:

    UIApplicationLaunchOptionsURLKey //通过openURL: 启动

    UIApplicationLaunchOptionsSourceApplicationKey //应用程序的bundle ID

    UIApplicationLaunchOptionsRemoteNotificationKey //远程通知启动

    UIApplicationLaunchOptionsLocalNotificationKey //本地通知启动

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

        NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
        NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];

        if(apsInfo) {
           
          NSlog(@"%@",
    apsInfo);
            return YES;
        }
        return YES;
    }

    一般 在APP 启动的时候会做激活网络、设置导航栏、注册用户代理、判断是否首次登录、启动动画

    激活网络:

        [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];

        [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    设置导航栏:
      

    //barItem背景颜色

        [[UINavigationBar appearance] setBarTintColor:[UIColor hex:@"#222028"]];

        //返回按钮颜色

        [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

        [[UINavigationBar appearance] setTitleTextAttributes:@{

                                                               NSForegroundColorAttributeName:[UIColor whiteColor]

                                                               

                                                               }

         ];

    注册用户代理:

    #import "sys/utsname.h"

        

    - (void)registerUserAgent{

        //区分客户端访问类型 是否是IOSAndroidWeb

        

         struct utsname systemInfo;

        uname(&systemInfo);

        NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];

        NSString *userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], deviceString, [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)];

        NSDictionary *dictionary = @{@"UserAgent" : userAgent};//User-Agent

        [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];

         

        /*

        UIWebView* tempWebView = [[UIWebView alloc] initWithFrame:CGRectZero];

        NSString* userAgent = [tempWebView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];

        //        NSLog(@"------%@",userAgent);

        NSString *executableFile = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey];

        NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];

        NSString *ua = [NSString stringWithFormat:@"%@ %@/%@", userAgent, executableFile,version];

        //        NSLog(@"------%@",ua);

        [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent" : ua, @"User-Agent" : ua}];

        NSLog(@"%@ ",ua);

         */

    }

     

    判断是否首次登录:
      

    if ([Login isLogin]) {

            [self setupTabViewController];

        }else{

            [UIApplication sharedApplication].applicationIconBadgeNumber = 0;

            [self setupIntroductionViewController];

        }

    启动动画:

      

       @weakify(self);

        [startView startAnimationWithCompletionBlock:^(EaseStartView *easeStartView) {

            @strongify(self);

            //启动动画完成后 做注册推送、注册统计、推送反馈

            [self completionStartAnimationWithOptions:launchOptions];

        }];

  • 相关阅读:
    Spring aop 记录操作日志 Aspect 自定义注解
    winSCP连接FTP没有上传的权限
    Ubantu下安装FTP服务器
    设置ubantu的软件源地址
    Ubantu中安装sublime
    Ubantu 新建用户后没有生成对应文件夹
    Spring aop 记录操作日志 Aspect
    Java中如何获取spring中配置文件.properties中属性值
    java中获取ServletContext常见方法
    解决:“java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut myMethod”问题!
  • 原文地址:https://www.cnblogs.com/air-liyan/p/6125175.html
Copyright © 2011-2022 走看看