Related integration methods can also refer directly to the Official document Http://www.rongcloud.cn/docs/ios.html. Here are some detailed steps in my integration process.
1. Preparation: To the official website http://www.rongcloud.cn Register login, create their own applications, get the application of the Appkey.
2. Integrated SDK, recommended to use cocoapods convenient
Target ' projectname ' Do # project name
pod ' rongcloudim/imlib '
pod ' rongcloudim/imkit '
end
3. Initialization: APPDELEGATE.M
#import <RongIMKit/RongIMKit.h> @interface appdelegate () <RCIMUserInfoDataSource>-(BOOL) Application: ( UIApplication *) Application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Melt cloud [[RCIM SharedRCIM]
initwithappkey:@ "Your Appkey"];
The normal development token is obtained from the app server, which can be obtained at the test interface of the official website [[Rcim Sharedrcim] Connectwithtoken:token success:^ (NSString *userid) { NSLog (@ "Landing successful.")
Currently logged in user id:%@ ", userId);
} error:^ (Rcconnecterrorcode status) {NSLog (@ "Login error code:%ZD", status);
tokenincorrect:^{//token is outdated or incorrect.
If the token expiration is set and the token expires, please request your server to obtain a new token///If the token error is not set for the token validity period, check your client and server Appkey for matching, and check your process for obtaining the token.
NSLog (@ "token error");
}];
Set up the proxy method to return the user information [[RCIM SHAREDRCIM] setuserinfodatasource:self];
return YES; //rcimuserinfodatasource Proxy Method-(void) Getuserinfowithuserid: (NSString *) userId Completion: (void (^) (Rcuserinfo *)) Completion {//each display user avatar and other information will be invoked, normal development should be obtained from the app server, saved in the local RcuserinFo *info = [[Rcuserinfo alloc] initwithuserid:userid name:@ ' name ' portrait:@ ' http://tx.haiqq.com/uploads/allimg/
160417/1_041f15kk0l.jpg "];
Completion (info); }
4. Session List: The default use of Rcconversationlistviewcontroller in Imkit, you can directly use or inherit
ChatListViewController.h
#import <RongIMKit/RongIMKit.h>
@interface Chatlistviewcontroller:rcconversationlistviewcontroller
Chatlistviewcontroller.m
-(void) viewdidload {[Super viewdidload]; Set the session that needs to display the list to display those types [self setdisplayconversationtypes:@[@ (conversationtype_private), @ (conversationtype_ DISCUSSION), @ (Conversationtype_chatroom), @ (Conversationtype_group),
@ (Conversationtype_appservice), @ (Conversationtype_system)];
Sets which types of sessions are aggregated to display in the session list [self setcollectionconversationtype:@[@ (conversationtype_discussion),
@ (Conversationtype_group)]]; //Click Reply to jump to the reply page-(void) Onselectedtablerow: (rcconversationmodeltype) Conversationmodeltype Conversationmodel: ( Rcconversationmodel *) Model Atindexpath: (Nsindexpath *) Indexpath {//Session page: Direct use or inheritance Rcconversationviewcontroller RCCon
Versationviewcontroller *CONVERSATIONVC = [[Rcconversationviewcontroller alloc]init];
Conversationvc.conversationtype = Model.conversationtype;
Conversationvc.targetid = Model.targetid; Conversationvc.title = Model.conversatIontitle;
conversationvc.hidesbottombarwhenpushed = YES;
[Self.navigationcontroller PUSHVIEWCONTROLLER:CONVERSATIONVC Animated:yes]; }
5. Use the official API test
6. So far, the simple chat function has been realized
7. Remote message push can be http://www.rongcloud.cn/docs/ios_push.html by official steps.