使用
初始化
ProfileManager本身无需初始化,默认依赖基础库内置shark实例,因此在使用ProfileManager之前,需先初始化基础库。
说明:基础库初始化请参考:
- "将TMF添加到您的项目中"初始化部分
- "基础库API"
设置UserId
public static void setUserId(String userId);
参数名称 |
参数类型 |
参数描述 |
必选 |
userId |
String |
用户ID,传空值时表示解绑操作 |
Y |
listener |
IConchPushListener |
云指令下发监听接口 |
Y |
示例:
ProfileManager.setUserId("158xxxxxxxx");
地理位置上报
public static void setLocation(String country, String province, String city)
参数名称 |
参数类型 |
参数描述 |
必选 |
country |
String |
国家 |
Y |
province |
String |
省 |
Y |
city |
String |
市 |
Y |
设置标签
public static void setTag(String tag, String value)
参数名称 |
参数类型 |
参数描述 |
必选 |
tag |
String |
标签名,注意需要在控制台创建好相应标签 |
Y |
value |
String |
标签值,如果是限定值标签,值的范围需要在限定范围内 |
Y |
批量设置标签
public static void setTags(Map<String, String> tags)
参数名称 |
参数类型 |
参数描述 |
必选 |
tags |
Map |
key对应标签名,value对应标签值 |
Y |
标签设置错误监听器
public static void setTagErrorListener(ITagErrorListener listener)
public interface ITagErrorListener {
public void onError(List<TagResult> tagResults);
public class TagResult {
public String mTagKey;
public String mTagValue;
public int mErrorCode;
}
}
public class TagErrorCode {
public static final int ERR_NONE = 0;
public static final int ERR_ISharkNullError = -997;
public static final int ERR_TagNullError = -998;
public static final int ERR_NetworkError = -999;
public static final int ERR_ServerError = -1001;
public static final int ERR_SDKInnerError = -1002;
public static final int ERR_ReportTagNotAvai = -1004;
public static final int ERR_ReportTagValueNotAvai = -1005;
public static final int ERR_ReportTagValueTooLong = -1006;
}