iOS环信集成<1>

         今天周末,想着没事就写写代码,因为基础底子比较弱,所以联系加了4个月班学习,总之现在已经养成每天学习新的知识的习惯。大学拿了三年奖学金出来转iOS,真的是隔行如隔山,有些事不是努力就一定成长,但是不努力就是下层码农,没有办法我们没有格局,只能谈代码。后期有时间准备写程序猿和非程序猿的精神差距与格局。好了,写写今天集成环信的第一天写的demo以及步骤吧,希望大家多多提建议,起码知道不没有白写。

一.在环信上注册环信账号

二.在环信官网上注册一个appkey,这个appkey很重要,我们app启动的时候需要这把发动机的钥匙。

环信注册教程->

三.推送证书。这个我是第一次接触,所以没有去注册推送证书。基本可以有appkey可以实现聊天这些功能。

推送证书

四.下载环信的sdk目前环信已经升级,我拿的是15年时候下载的sdk。

环信sdk->

五.集成



六.打开sdk并集成到项目里

libEaseMobClientSDKLite.a不包含实时语音功能,libEaseMobClientSDK.a包含所有功能。

七.集成依赖库 

我集成的是全部功能所以删掉了libEaseMobClientSDKLite.a保留了libEaseMobClientSDK.a这个库

配置文件库



  八.编辑工程

//
//  AppDelegate.m
//  LXP微信
//
//  Created by chuangqu on 16/4/24.
//  Copyright © 2016年 mr.liu. All rights reserved.
//
#define APPKEY      @"xxx"     //环信APPKEY
#define APNSCert    @"xxx"          //环信推送证书名称
#import "AppDelegate.h"
#import "EaseMob.h"
#import "FirstViewController.h"
#import "GroupMessageViewController.h"
#import "MessageViewController.h"
#import "SeetingsViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    //初始化环信SDK
    [[EaseMob sharedInstance] registerSDKWithAppKey:APPKEY apnsCertName:APNSCert];
    
    //异步登陆的方法
    [[EaseMob sharedInstance].chatManager asyncLoginWithUsername:@"yuancan001" password:@"123" completion:^(NSDictionary *loginInfo, EMError *error) {
        if (!error && loginInfo) {
            NSLog(@"登陆成功");
            
            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"log"];
            
            [[EaseMob sharedInstance].chatManager setIsAutoFetchBuddyList:YES];

            [self setUP];

        }
    } onQueue:nil];


    [self.window makeKeyAndVisible];
    
    return YES;
}
/**
 *tabr 根控制器
 *
 *
 */
- (void)setUP{
    
    FirstViewController *first = [[FirstViewController alloc] init];
    GroupMessageViewController *group = [[GroupMessageViewController alloc] init];
    SeetingsViewController *seetings = [[SeetingsViewController alloc] init];
    
    MessageViewController *message = [[MessageViewController alloc] init];
    
    first.title = @"好友列表";
    group.title = @"群消息";
    seetings.title = @"设置";
    message.title = @"消息";
    
    UITabBarController *tabBar = [[UITabBarController alloc] init];

    tabBar.viewControllers = @[[[UINavigationController alloc]initWithRootViewController:first],[[UINavigationController alloc] initWithRootViewController:group],[[UINavigationController alloc] initWithRootViewController:seetings],[[UINavigationController alloc] initWithRootViewController:message]];

    self.window.rootViewController = tabBar;
    self.window.backgroundColor = [UIColor whiteColor];
    
}

- (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 throttle down OpenGL ES frame rates. 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 inactive 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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值