Class Info |
|---|
public class HmsProfile 根据帐号校验是否显示当前用户消息功能的类。 |
Qualifier and Type | Field and Description |
|---|---|
public static final int | 帐号校验功能的类型,表示关联华为帐号。 |
public static final int | 帐号校验功能的类型,关联其他帐号(非华为帐号)。 |
Qualifier and Type | Method Name and Description |
|---|---|
static HmsProfile | getInstance(Context context) 获取HmsProfile类实例。 |
boolean | 判断当前终端设备是否支持帐号校验功能。 |
Task<Void> | addProfile(int type, String profileId) 添加当前设备上该用户与应用的关系。 |
Task<Void> | addProfile(String subjectId, int type, String profileId) 多发送者场景下,添加当前设备上该用户与应用的关系。 |
Task<Void> | deleteProfile(String profileId) 清除当前设备上该用户与应用的关系。 |
Task<Void> | deleteProfile(String subjectId, String profileId) 多发送者场景下,清除当前设备上该用户与应用的关系。 |
Fields |
|---|
public static final int HUAWEI_PROFILE 您调用HmsProfile中的addProfile()方法传入帐号校验类型参数的值,表示关联华为帐号。 另请参阅:Constant-values |
Fields |
|---|
public static final int CUSTOM_PROFILE 您调用HmsProfile中的addProfile()方法传入帐号校验类型参数的值,表示关联其他帐号(非华为帐号)。 另请参阅:Constant-values |
Method |
|---|
public static HmsProfile getInstance(Context context) 获取HmsProfile类对象实例,如果该实例不存在,则会创建实例。只有获取到实例后才能调用本类中的其他方法。 |
Parameters
Name | Description |
|---|---|
context | 应用上下文。 |
Returns
Type | Description |
|---|---|
HmsProfile | 实例对象。 |
Throws
Name | Description |
|---|---|
NullPointerException | 入参为空引用导致的异常。 |
Method |
|---|
public boolean isSupportProfile() 判断当前终端设备是否支持帐号校验功能。 |
Returns
Type | Description |
|---|---|
boolean |
|
Method |
|---|
public Task<Void> addProfile(int type, String profileId) 添加当前设备上的用户与应用的关系。 |
Parameters
Name | Description |
|---|---|
type | 帐号校验功能的类型。
|
profileId | 若当前设备支持帐号校验能力,应用发送的消息需要校验帐号,profileId是您给帐号生成的帐号的唯一标识。 |
Returns
Type | Description |
|---|---|
Task<Void> | 异步任务,应用需要通过addOnCompleteListener来获取响应结果。 |
Method |
|---|
public Task<Void> addProfile(String subjectId, int type, String profileId) 多发送者场景下,添加当前设备上的用户与应用的关系。 |
Parameters
Name | Description |
|---|---|
subjectId | 发送者的项目ID,登录AppGallery Connect网站,选择“我的项目”,在项目列表中选择对应的项目,左侧导航栏选择“项目设置”,在该页面获取发送者的项目ID。 |
type | 帐号校验功能的类型,1表示关联华为帐号(HmsProfile.HUAWEI_PROFILE),2表示关联其他帐号,非华为帐号(HmsProfile.CUSTOM_PROFILE)。 |
profileId | 若当前设备支持帐号校验能力,应用发送的消息需要校验帐号,profileId是您给帐号生成的帐号的唯一标识。 |
Returns
Type | Description |
|---|---|
Task<Void> | 异步任务,应用需要通过addOnCompleteListener来获取响应结果。 |
public Task<Void> deleteProfile(String profileId) 清除当前设备上登录的用户与应用的关系。 |
Parameters
Name | Description |
|---|---|
profileId | 若当前设备支持帐号校验能力,应用发送的消息需要校验帐号,profileId是您给帐号生成的帐号的唯一标识。 |
Returns
Type | Description |
|---|---|
Task<Void> | 异步任务,应用需要通过addOnCompleteListener来获取响应结果。 |
Method |
|---|
public Task<Void> deleteProfile(String subjectId, String profileId) 多发送者场景下,清除当前设备上登录的用户与应用的关系。 |
Parameters
Name | Description |
|---|---|
subjectId | 发送者的项目ID,登录AppGallery Connect网站,选择“我的项目”,在项目列表中选择对应的项目,左侧导航栏选择“项目设置”,在该页面获取发送者的项目ID。 |
profileId | 若当前设备支持帐号校验能力,应用发送的消息需要校验帐号,profileId是您给帐号生成的帐号的唯一标识。 |
Returns
Type | Description |
|---|---|
Task<Void> | 异步任务,应用需要通过addOnCompleteListener来获取响应结果。 |