当前位置:网站首页>30 minutes integrated cloud instant messaging

30 minutes integrated cloud instant messaging

2020-12-08 10:33:47 osc_ 4hvlwoqt

Recently, the company is going to do a social networking app, In today's society where time is money , It's certainly not cost-effective to recruit a lot of people to build communication systems , It was made with human, material and financial resources app, Maybe no one's using it yet . Then you're blind . So there is no doubt , Hit it off , With third party . The beginning of the current market for the mainstream third party IM SDK Conduct research . Among them, Tencent cloud , Netease Yunxin , Melting clouds , Ring letter, etc . List a bunch of contrast conditions , Which is the final decision of the leader . End programmers have no choice . Just move the bricks well ~ Know who you are , Quack

The process is over , Finally, we chose to use rongyun , I don't say much nonsense , Direct ~ Here's just how to quickly integrate , Let the two talk , This is also a milestone . For programmers , If you can't talk, it's ruined , The leader of Dutchman is fierce ~~~

1. Go to rongyun official website first To register , This can be done by your product manager or leader , You can use the email address of the company , Don't use your own , Later I changed places , It's also a loss to the company, not . Add apps after registration , Get appkey

2.xcode Create a new project , Or find your own company's project , Here I recommend pod How to manage third parties , Convenient and quick , Time saving and labor saving . Because the manual mode is too backward , And the configuration is cumbersome , A slight omission will result in an error , Some reports are wrong. It takes a lot of time, energy and energy to check them out , So it's a matter of fact pod Well . Don't listen to old people , Lose at present , Listen to brother's right , The fusion cloud document describes how to use pod, A few lines of command . After that , That is the SDK Integrated , Run the project , If no error is reported , Congratulations to your brother , We can chat soon , Look at the next step

3. Need to be in appDelegate Import header file .#import <RongIMKit/RongIMKit.h>. by the way , We're using the interface SDK, Fast integration is easy .

4. initialization SDK

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // You need to replace the quotation marks with your  appkey, Don't copy it intact , Quack 
    [[RCIM sharedRCIM] initWithAppKey:@" Integrate cloud developer background  AppKey"];
    return YES;
}

5. It's time to connect, brother

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[RCIM sharedRCIM] initWithAppKey:@" Acquired  AppKey"];

    [[RCIM sharedRCIM] connectWithToken:@" Developer's  server  By request  server api  Acquired  token  value "
                           dbOpened:^(RCDBErrorCode code) {}
                            success:^(NSString *userId) {}
                              error:^(RCConnectErrorCode status) {}];

    return YES;
}

On the blackboard 1: I have to say more about you here , You have to look at the calls of successful callbacks and failed callbacks , Enter success It's a success , Enter error It's just a mistake . It's a mistake. You have to see status Status code , Look for problems according to the error code . I met in the process of debugging RC_CONN_TOKEN_INCORRECT Error code , seeing the name of a thing one thinks of its function :token Incorrect . This is to find their own server-side staff to see where the problem is caused by token It's not true .

On the blackboard 1: also @" Developer's server By request server api Acquired token value ", This token, At the beginning of the test , Your server may not be integrated yet , So you can go to the background of rongyun developers first “ Service management ” - “API call ” - “ Customer service ” - “ obtain Token” Where? , Just type in any one userId,name,portraitUri, You can get it. token 了 . Use this token Just connect , Time saving and labor saving .

6. thus , Congratulations , It has been connected to rongyun successfully . The next step is to figure out how to talk to people .

7. Chat , It takes two people , Right , Now one of the connected users is , Another need to go to the cloud developer background to apply for another token, Remember his userId, It's necessary to send a message userId Of . And then create a button , Click the event and write the following code , After the jump , You can talk . And then run a simulator or a real machine , Applied after use token land , They can talk to each other .

RCConversationViewController *chatViewController = [[RCConversationViewController alloc] initWithConversationType:ConversationType_PRIVATE targetId:" Post application  token  When you fill in  userId"];
[self.navigationController pushViewController:chatViewController animated:YES];

版权声明
本文为[osc_ 4hvlwoqt]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201208103246373e.html