로그인

Prev Next

Classic/VPC 환경에서 이용 가능합니다.

로그인

초기화 완료 후 사용자명, 이름, 프로필 이미지 주소(옵션)를 입력하여 접속할 수 있습니다.

접속

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 아이디 O
NAME string 닉네임 X
PROFILE_URL string 프로필 주소 URL X
LANGUAGE string 언어코드 X
CUSTOM_FIELD string 사용자 정의 필드 X
TOKEN string 토큰 값 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 아이디 O
NAME String 닉네임 X
PROFILE_URL String 프로필 주소 URL X
LANGUAGE String 언어코드 X
CUSTOM_FIELD String 사용자 정의 필드 X
TOKEN String 토큰 값 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 아이디 O
NAME String 닉네임 X
PROFILE String 프로필 주소 URL X
CUSTOM_FIELD String 사용자 정의 필드 X
TOKEN String 토큰 값 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* 아이디 O
NAME NSString* 닉네임 X
PROFILE NSString* 프로필 주소 URL X
CUSTOM_FIELD NSString* 사용자 정의 필드 X
TOKEN NSString* 토큰 값 X

Unity

await nc.Connect(
    id: [USERNAME],
    name: [NAME],
    profile: [PROFILE_URL],
    customField: [CUSTOM_FIELD],
    token: [TOKEN]
);
ID Type Description Required
USERNAME string 아이디 O
NAME string 닉네임 X
PROFILE_URL string 프로필 주소 URL X
LANGUAGE string 언어코드 X
CUSTOM_FIELD string 사용자 정의 필드 X
TOKEN string 토큰 값 X
참고
  • 로그인 시 보안을 위해 API로 토큰을 발급받는 것을 권장합니다.
  • API DOCS TOKEN API를 통해 발급된 토큰을 사용할 수 있습니다.
  • 토큰 방식을 사용하지 않으실 경우 대시보드 > 보안설정 > Token 인증사용 안함으로 설정해 주십시오.

접속 종료

연결된 Ncloud Chat 서버와의 연결을 해제하려면 아래 코드를 사용해 주십시오.

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();

사용자 정보

  • Member Data Class
ID Type Description
id string 사용자 ID
name string 사용자 이름
profile string 이미지 주소

사용자 정보 가져오기

특정 아이디에 대한 정보를 가져옵니다(보안상 닉네임만 전달됩니다).

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) {
        // 오류
    } else {
        // 성공
    }
}

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) :
        // 성공
        break;
    case .failure(let 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) {
        // 오류
    } else {
        // 성공
    }
}];

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 쿼리를 필터 모든 필드에 대해서 검색 가능 O
sort object 소트 하고자 하는 필드의 필터 정의 (오름차순 "1", 내림차순 "-1") X
option object 옵션이 존재할 경우 아래 참고 X
  • Options
ID Type Description
offset number 시작 offset
per_page number 리턴하는 개수(최대 100개)