Skip to main content

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​

  1. Create Unity Project: Start by creating a new Unity project. Then, clone open-im-sdk-unity into the Assets directory.

  2. Import Namespace: Import the necessary namespace in your scripts:

    using OpenIM.IMSDK.Unity;
    using OpenIM.IMSDK.Unity.Listener;
  3. Initialize SDK: Initialize the OpenIMSDK by calling the InitSDK method:

    var suc = IMSDK.InitSDK(IMConfig config, IConnCallBack connCallBack);
  4. Set Listeners: Set up listeners for various events:

    // Conversation listener
    IMSDK.SetConversationListener(conversation);
    // Friendship listener
    IMSDK.SetFriendShipListener(friendship);
    // Group listener
    IMSDK.SetGroupListener(group);
  5. 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);
  6. Logout: Perform logout when necessary:

    IMSDK.Logout((suc,errCode,errMsg)=>{

    });
  7. 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.