AppDelegate.m 3.98 KB
//
//  AppDelegate.m
//  LiveVideoCloud
//
//  Created by 张旭 on 2017/3/7.
//  Copyright © 2017年 cnlive. All rights reserved.
//

#import "AppDelegate.h"
#import "ZXTabBarController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.rootViewController = [[ZXTabBarController alloc] init];
    
    //测试环境开关,只在初始化时有效
    self.isTestEnvironment = YES;
    
    //APP 启动是初始化直播SDK
    [[CNLiveWebcastManager manager] initWithAppId:UserAppId appKey:UserAppKey isTestEnvironment:self.isTestEnvironment];
    
    // 初始化评论功能
    [[CNLiveCommentManager sharedCNLiveCommentManager] registerWithAppId:UserAppId appKey:UserAppKey isTestEnvironment:YES];
    
    //初始化用户SDK
    [CNLiveUserSystemCenter setAppId:UserAppId appKey:UserAppKey appSecret:UserAppSceret isTestEnvironment:self.isTestEnvironment];
    
    //初始化聊天SDK并连接服务器
    [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:UserAppKey appId:UserAppId isTestEnvironment:self.isTestEnvironment];
    
    /*
     [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
     NSLog(@"连接服务器-----success");
     } error:^(CNLiveChatConnectErrorCode errors) {
     NSLog(@"连接服务器失败-----%ld", errors);
     }];
     */
    
    /*
     CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170311" name:@"zzllzzzll" portrait:@"https://y3.cnliveimg.com/mobile/images/mobilehead/2017/03/30/1490844962259_small.jpg"];
     */

    // 20170327 20170328


    CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"2017063339" name:@"设计的" portrait:@"http://b.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=f0c5c08030d3d539c16807c70fb7c566/8ad4b31c8701a18bbef9f231982f07082838feba.jpg"];


    [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) {
        NSLog(@"连接服务器-----success");
        
    } error:^(CNLiveChatConnectErrorCode errors) {
        NSLog(@"连接服务器失败-----%ld", errors);
    }];
    
    [self.window makeKeyAndVisible];
    
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end