Login

Prev Next

Available in Classic and VPC

Login

Once the initialization is complete, you can enter the username, name, and profile image address (optional) to access.

Access

Javascript/TypeScript

await nc.connect({
    id: [USERNAME],
    name: [NAME],
    profile: [PROFILE_URL],
    language: [LANGUAGE],
    customField: [CUSTOM_FIELD],
    token: [TOKEN]
});
ID Type Description Required
USERNAME string ID O
NAME string Nickname X
PROFILE_URL string Profile address URL X
LANGUAGE string Language code X
CUSTOM_FIELD string User-defined field X
TOKEN string Token value X

Android (Kotlin)

NChat.Connect([USERNAME], [NAME], [PROFILE_URL], [LANGUAGE], [CUSTOM_FIELD], [TOKEN]) { user, e ->
    if (e != null) {
        // Error
    } else {
        // Success
    }
}
ID Type Description Required
USERNAME String ID O
NAME String Nickname X
PROFILE_URL String Profile address URL X
LANGUAGE String Language code X
CUSTOM_FIELD String User-defined field X
TOKEN String Token value X

iOS (Swift)

NChat.Connect(userId: [USER_ID], name: [NAME], profile: [PROFILE], customField: [CUSTOM_FIELD], token: [TOKEN]) { result in
    switch(result)
    {
    case .success(let user) :
        break;
    case .failure(let error) :
        break;
    }
}
ID Type Description Required
USER_ID String ID O
NAME String Nickname X
PROFILE String Profile address URL X
CUSTOM_FIELD String User-defined field X
TOKEN String Token value X

iOS (Objective-C)

[NChatBridge.shared ConnectWithUserId:[USER_ID] name:[NAME] profile:[PROFILE] customField:[CUSTOM_FIELD] token:[TOKEN] :^(NSDictionary * _Nullable result, NSError * _Nullable error) {
    if (error) {
        // Error
    } else {
        // Success
    }
}];
ID Type Description Required
USER_ID NSString* ID O
NAME NSString* Nickname X
PROFILE NSString* Profile address URL X
CUSTOM_FIELD NSString* User-defined field X
TOKEN NSString* Token value X

Unity

await nc.Connect(
    id: [USERNAME],
    name: [NAME],
    profile: [PROFILE_URL],
    customField: [CUSTOM_FIELD],
    token: [TOKEN]
);
ID Type Description Required
USERNAME string ID O
NAME string Nickname X
PROFILE_URL string Profile address URL X
LANGUAGE string Language code X
CUSTOM_FIELD string User-defined field X
TOKEN string Token value X
Note
  • Obtain a token through the API for login security.
  • You can use the token issued through API DOCS TOKEN API.
  • If you do not want to use the token method, set disable in Dashboard > Security settings > Token authentication.

Terminate access

Use the code below to disconnect from the connected Ncloud Chat server.

Javascript/Typescript

await nc.disconnect();

Android (Kotlin)

NChat.Disconnect();

iOS (Swift)

NChat.Disconnect() { result in
    switch(result)
    {
    case .success(let status) :
        break;
    case .failure(let error) :
        break;
    }
}

iOS (Objective-C)

[NChatBridge.shared Disconnect:^(NSNumber * _Nullable result, NSError * _Nullable error) {
    if (error) {
        // Error
    } else {
        // Success
    }
}];

Unity

await nc.Disconnect();

User information

  • Member Data Class
ID Type Description
id string User ID
name string Username
profile string Image address

Import user information

Imports information about a specific ID (only the nickname is sent for security reasons).

Javascript/Typescript

const filter = { id: user_id };
const sort = { created_at: -1 };
const option = { offset: 0, per_page: 100 };
const members = await nc.getUsers(filter, sort, option);

Android (Kotlin)

val filter: Map<String, Any?> = mapOf(
    "id" to [USER_ID]
)
val sort: Map<String, Any?> = mapOf(
    "created_at" to -1
)
val options: Map<String, Any?> = mapOf(
    "per_page" to 10,
    "offset" to 0
)
NChat.getUsers(filter, sort, options) { user, e->
    if (e != null) {
        // Error
    } else {
        // Succeeded
    }
}

iOS (Swift)

let filter: [String: Any] = ["id": [USER_ID]]
let option: [String: Any] = ["per_page": 10, "offset": 0]
let sort: [String: Any] = ["created_at": "-1"]
NChat.getUsers(filter: filter, option: option, sort: sort) { result in
    switch(result)
    {
    case .success(let messages) :
        // Succeeded
        break;
    case .failure(let error) :
        // Error
        break;
    }
}

iOS (Objective-C)

NSDictionary *filter = @{@"id": [USER_ID]};
NSDictionary *option = @{@"per_page": @10, @"offset": @0};
NSDictionary *sort = @{@"created_at": @"-1"};
[NChatBridge.shared getUsersWithFilter:filter option:option sort:sort :^(NSDictionary * _Nullable result, NSError * _Nullable error) {
    if (error) {
        // Error
    } else {
        // Succeeded
    }
}];

Unity

Hashtable filter = new Hashtable
{
    { "id", [USER_ID] }
};
Hashtable sort = new Hashtable
{
    { "created_at", -1 }
};
Hashtable option = new Hashtable
{
    { "offset", 0 },
    { "per_page", 10 }
};
var users = await nc.getUsers(filter, sort, option);
  • Parameters
ID Type Description Required
filter object Search is available for all fields of a query through filtering O
sort object Define the filter for the fields you want to sort ("1" for ascending, "-1" for descending order) X
option object See the following when there are options X
  • Options
ID Type Description
offset number Start offset
per_page number Number of items returned (up to 100)