• 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];

        }];

  • 相关阅读:
    SQL Server 2005 上安装SQL Server Management Studio
    小心博客被Google点名为有恶意软件
    新文章尚邮使用评论 ,包含Gmail的设置以及存在的一些问题
    发布一小软件
    在 ASP.NET 上实现锁定表头、支持滚动的表格的做法
    怎样检测网络中的电脑是否有安装SQL 2000
    危险字符过滤的类
    通过避免下列 10 个常见 ASP.NET 缺陷使网站平稳运行(转载)
    javascript控制页面控件隐藏显示的两种方法
    整理的一些Tsql(二)
  • 原文地址:https://www.cnblogs.com/air-liyan/p/6125175.html
Copyright © 2020-2023  润新知