Unity
đ Usage Demoâ
We strongly recommend running the framework-related example DEMO prepared for you first. This will not only allow you to experience the functionality of OpenIMSDK intuitively but also help you quickly locate and resolve issues during the actual integration process.
Integration Stepsâ
Create Unity Project: Start by creating a new Unity project. Then, clone open-im-sdk-unity into the
Assets
directory.Import Namespace: Import the necessary namespace in your scripts:
using OpenIM.IMSDK.Unity;
using OpenIM.IMSDK.Unity.Listener;Initialize SDK: Initialize the OpenIMSDK by calling the
InitSDK
method:var suc = IMSDK.InitSDK(IMConfig config, IConnCallBack connCallBack);
Set Listeners: Set up listeners for various events:
// Conversation listener
IMSDK.SetConversationListener(conversation);
// Friendship listener
IMSDK.SetFriendShipListener(friendship);
// Group listener
IMSDK.SetGroupListener(group);Login: Before logging in, make sure to set up the listeners. Then, initiate the login process:
IMSDK.Login((suc,errCode,errMsg)=>{
},string uid, string token);Logout: Perform logout when necessary:
IMSDK.Logout((suc,errCode,errMsg)=>{
});Quit: When closing your application, make sure to release SDK resources:
IMSDK.UnInitSDK();
These steps should guide you through the process of integrating OpenIMSDK into your Unity project seamlessly.