Welcome toTencent Cloud + community, get more Tencent mass technology practice dry goods oh ~

This article is published in cloud + community column by Tencent Cloud Video

Pay attention to the public, “tencent cloud video”, a key access technology dry | | preferential activities video solutions

“Where are we going for dinner tonight?”

The desktop comes from a dialog box about dinner in the evening – QQ.

Suddenly a flash of inspiration, the new OPTIMIZED IM SDK, you can try to build a similar QQ instant messaging software

01

Registered account

Tencent Cloud official website

Register a Tencent cloud account, or log in directly using QQ or wechat

02

Create an

Select [Products] → [Cloud Communications] → [Use now] → [Create application access]

03

The SDK access

1. Integrate SDK

Cloud communication SDK includes IMSDK (Cloud communication SDK), TUIKit (basic interface library)

2. Generate UserSig

Download the public and private keys in [Basic Configuration], and use [Development assistance Tools] to generate the UserSig of the test user

Initialize the SDK

The Android code

 // When the Application starts (usually onCreate of the Application), configure the basic UIKit configuration. For details, refer to the API
    BaseUIKitConfigs uiKitConfigs = new BaseUIKitConfigs();
    uiKitConfigs.appCacheDir(Constants.APP_DIR_CACHE).audioRecordMaxTime(120)
                .disableAudioPlayedStatusIcon(true).disableAutoPlayNextAudio(true)
                .ChatProcessor(new PojoChatProcessor());
    ILiveUIKit.init(this, uiKitConfigs);
Copy the code

4. Create a login interface

The Android code

 public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Instantiate the login panel
        mLoginPanel = new LoginView(this);
        // Set the login component to the basic layout of the login Activity, or reference the LoginView in the layout file XML
        setContentView((View) mLoginPanel);
        // Add action events for the login component, login click and register click
        mLoginPanel.setLoginEvent(new ILoginEvent() {
            @Override
            public void onLoginClick(View view, String userName, String password) {
                // Click login to log in business's own logon logic
            }

            @Override
            public void onRegisterClick(View view, String userName, String password) {
                // Click on the business's own registration logic when registering}}); }Copy the code

Interface there are800,000 monographs

Create a session list

Layout file

<! Reference the session list component in the session list layout file, or set it in code by referring to the Login panel --> <? The XML version = "1.0" encoding = "utf-8"? > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".main.MainActivity"> <com.tencent.qcloud.uikit.business.session.view.SessionPanel android:id="@+id/session_panel" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>Copy the code

The Android code

 /** * Get session list component, initialize default Settings * Session component's default Settings already implement session data pull and processing (associated with IMSDK to complete related logic) * Developers can directly initialize default Settings for special requirements * and session component provides extensible event and UI processing, Refer to the API documentation */ for details
sessionPanel = baseView.findViewById(R.id.session_panel);
sessionPanel.initDefault();
Copy the code

Interface there are800,000 monographs

6. Create a chat interface

The Android code

// Get the chat panel component from the layout file
chatPanel = mBaseView.findViewById(R.id.chat_panel);
/* * The default Settings of the session component already implement session data pulling and processing (associated with the IMSDK to complete the related logic) * Developers can directly initialize the default Settings without special requirements * and the extensible event and UI processing provided by the Chat panel component, refer to the API documentation */
chatPanel.initDefault();
// Generate basic chat information, such as the chat object's nickname, avatar, last page chat information, etc
BaseChatInfo info = getChatInfo();
// Set basic information so that users can display relevant information when they enter the page
chatPanel.setBaseChatInfo(info);
Copy the code

Interface there are800,000 monographs

7. Group management

The Android code

// Get the group Management panel component from the layout file
GroupManagerPanel groupManagerPanel = mBaseView.findViewById(R.id.group_manager_panel);
/* * The default Settings of the group manager component already implement the group management-related logic operation (associated with the IMSDK to complete the related logic) * developers can directly initialize the default Settings without special requirements * another extensible event and UI handling provided by the group manager component, refer to the API documentation */
groupManagerPanel.initDefault();
Copy the code

Interface there are800,000 monographs

Through the above steps, an INSTANT messaging App with single chat and group chat is completed

Worship their hands again, can build an APP in a day, la la la la la ~

Finally, take a look at the optimized new version of the IM SDK

IM SDK

Volume optimization

1. Android SO volume <1M

2. The volume increment of ios is less than 2 m

Performance optimization

1. Thread clipping (single-threaded architecture to reduce thread switching and thread synchronization costs)

2. CPU usage optimization (thread clipping, code logic optimization)

Message arrival rate

Deep optimization of the business logic layer, session policy layer and network layer to achieve four nine (99.99%) message arrival rate

Data monitoring

User-level data monitoring, real-time tracking and statistics of user behavior

  1. dau/mau
  2. Function of statistical
  3. User distribution

Overseas publication

Increase the overseas distribution of rich media messages to speed up the uploading and downloading of pictures, videos and voice files

Version compatibility

Compatible with older versions to achieve seamless switching

UIKit plug-in

A set of multi-functional custom interface library, to achieve session list, chat, contact, group management, bullet screen interface, customer access in a day

Question and answer

How does small program instant messaging access to send messages?

reading

Implementation principles of IM Instant messaging

IOS instant messaging + imitation wechat chat framework + source code

Start with these steps to create an instant messaging App

Machine learning in action! Quick introduction to online advertising business and CTR knowledge

This article has been authorized by the author to Tencent Cloud + community, more original text pleaseClick on the

Search concern public number “cloud plus community”, the first time to obtain technical dry goods, after concern reply 1024 send you a technical course gift package!

Massive technical practice experience, all in the cloud plus community!