TudadaStore API
TudadaStore API (클라우드 스토리지)
디바이스와 무관하게 사용자 데이터를 클라우드에 저장/조회합니다.
용량 제한: value 최대 2KB
getTudadaStore()
TudadaStore 싱글톤 인스턴스를 반환합니다.
반환값:
| 필드 | 타입 | 설명 |
|---|---|---|
| (반환값) | TudadaStore | 클라우드 스토리지 인스턴스 |
인스턴스 메서드:
| 멤버 | 타입 | 설명 |
|---|---|---|
get(options) | void | 클라우드에서 데이터 조회 |
save(options) | void | 클라우드에 데이터 저장 |
store.get(options) 옵션:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
key | string | ✅ | 조회할 키 |
success | function | - | 성공 콜백 |
fail | function | - | 실패 콜백 |
complete | function | - | 완료 콜백 |
store.get 성공 응답:
| 필드 | 타입 | 설명 |
|---|---|---|
value | string | null | 저장된 값 (없으면 null) |
store.save(options) 옵션:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
key | string | ✅ | 저장할 키 |
value | string | ✅ | 저장할 값 (최대 2KB) |
success | function | - | 성공 콜백 |
fail | function | - | 실패 콜백 |
complete | function | - | 완료 콜백 |
const store = TudadaSDK.getTudadaStore();
// 값 저장 (최대 2KB)
store.save({
key: 'userScore',
value: '1000',
success: () => console.log('클라우드 저장 완료'),
fail: (err) => console.error('저장 실패:', err.errMsg),
});
// 값 조회
store.get({
key: 'userScore',
success: (res) => {
if (res.value !== null) {
console.log('점수:', res.value);
} else {
console.log('저장된 값 없음');
}
},
});
tudadaStoreGet(options) / tudadaStoreSave(options)
TudadaStore를 직접 호출하는 방식입니다.
tudadaStoreSave(options) 옵션:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
key | string | ✅ | 저장할 키 |
value | string | ✅ | 저장할 값 (최대 2KB) |
success | function | - | 성공 콜백 |
fail | function | - | 실패 콜백 |
complete | function | - | 완료 콜백 |
tudadaStoreGet(options) 옵션:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
key | string | ✅ | 조회할 키 |
success | function | - | 성공 콜백 |
fail | function | - | 실패 콜백 |
complete | function | - | 완료 콜백 |
tudadaStoreGet 성공 응답:
| 필드 | 타입 | 설명 |
|---|---|---|
value | string | null | 저장된 값 (없으면 null) |
// 저장
TudadaSDK.tudadaStoreSave({
key: 'gameState',
value: JSON.stringify({ level: 5, coins: 300 }),
success: () => console.log('저장 완료'),
fail: (err) => console.error('저장 실패:', err.errMsg),
});
// 조회
TudadaSDK.tudadaStoreGet({
key: 'gameState',
success: (res) => {
if (res.value) {
const state = JSON.parse(res.value);
console.log('레벨:', state.level);
}
},
});