删除数据
用于删除已保存的游戏数据的 API。
URL 确认
此 API 使用 service-storage-api.playnanoo.com 域名。
API 信息
- URL:
https://service-storage-api.playnanoo.com/storage/v20230801/delete - Method:
PUT - 需要认证: 是
DeviceInfo 继承
此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性会自动包含。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| storage_key | string | 必填 | 要删除的数据键 |
响应数据
Res 类
| 字段 | 类型 | 说明 |
|---|---|---|
| Status | string | 处理状态 |
Unity C# 实现
BaseResponse 类
所有 API 响应的基类。
public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}
字段说明:
ErrorCode:错误代码Message:错误信息WithdrawalKey:账号处于注销等待状态时,用于恢复的密钥(仅注销等待中的账号提供)BlockKey:账号被封禁时提供的密钥(仅被封禁的账号提供)
删除数据类
using System;
using System.Collections;
using UnityEngine.Networking;
public class StorageDelete
{
static string path = "https://service-storage-api.playnanoo.com/storage/v20230801/delete";
[Serializable]
public class Req : DeviceInfo
{
public string storage_key;
public IEnumerator Send(string storage_key, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(storage_key)) this.storage_key = storage_key;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string Status;
}
}
使用示例
public void DeleteGameData()
{
StorageDelete.Req req = new StorageDelete.Req();
StartCoroutine(req.Send(
storage_key: "old_game_data",
onSuccess: res =>
{
Debug.Log("데이터 삭제 성공");
Debug.Log($"상태: {res.Status}");
},
onError: error =>
{
Debug.LogError($"데이터 삭제 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
无法恢复
已删除的数据无法恢复。建议在删除重要数据前向用户确认。
选择性删除
仅删除指定键的数据。如需删除多个数据,需要为每个键单独调用 API。