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 |
ID |
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 |
ID |
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 |
ID |
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* |
ID |
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 |
ID |
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();
ユーザー情報
| ID |
Type |
Description |
| id |
string |
ユーザー ID |
| name |
string |
ユーザー名 |
| profile |
string |
画像アドレス |
ユーザー情報を取得する
特定の IDに関する情報を取得します(セキュリティ上、ハンドルネームのみ転送します)。
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);
| ID |
Type |
Description |
Required |
| filter |
object |
クエリをフィルタ。すべてのフィールドに対して検索可能 |
O |
| sort |
object |
ソートしたいフィールドのフィルタを定義(昇順「1」、降順「-1」) |
X |
| option |
object |
オプションが存在する場合、以下を参照 |
X |
| ID |
Type |
Description |
| offset |
number |
開始 offset |
| per_page |
number |
リターン数(最大100個) |