Recent projects encountered the function of customer service, the first thought is the use of cloud features, because the previous instant messaging projects, with the integration of the Cloud SDK, took a little time to study the next, hope to help everyone!
Don't say much nonsense, the steps are as follows:
First, apply for cloud account
Second, create the application
Third, the opening of customer service, melting cloud of customer service integration is wisdom tooth customer services system, fully able to meet the use!
Four, after the opening of customer service services, will generate customer service Id,target ID is this, to enter the chat page before using
Five, into the application management interface, click API debugging, ID and username, as well as the Avatar URL can be randomly lost, testing, the following will be printed, generate a token
Six, the preparation work done, the following code:
-(Ibaction) Gochatclick: (ID) Sender {Chatviewcontroller*chatservice =[[Chatviewcontroller alloc] init];#defineservice_id @ "KEFU149269681191160"Chatservice.namestr=@"Customer Service"; Chatservice.conversationtype=Conversationtype_customerservice; Chatservice.targetid=service_id; Chatservice.title=Chatservice.namestr; [Self.navigationcontroller Pushviewcontroller:chatservice Animated:yes]; }-(Ibaction) Creatrongcloudclick: (ID) Sender {//register a cloud server[[Rcim Sharedrcim] initwithappkey:rongkey]; [[Rcim Sharedrcim] connectwithtoken:rongtoekn success:^ (NSString *userId) {NSLog (@"landed successfully. Currently logged in user id:%@", userId); } Error:^(Rcconnecterrorcode status) {NSLog (@"The login error code is:%ld", (Long) status); } tokenincorrect:^{ //token expires or is not correct. //If token expiration is set and token expires, please re-request your server for a new token//If the token expiration is not set and the token error is indicated, check to see if your client and server Appkey match and check your token acquisition process. NSLog (@"Token error"); }];}
Print as follows:
Chat that class directly inherit Rcconversationviewcontroller can, enter the page will be happy to chat!
At this point, the customer service function is complete!
iOS development-5 minutes of integrated cloud-enabled customer service